chtml40_t *chtml40;
Doc *doc;
request_rec *r;
- char *color = NULL;
+ char *attr_color = NULL;
+ char *attr_style = NULL;
chtml40 = GET_CHTML40(pdoc);
doc = chtml40->doc;
/* Get Attributes */
/*--------------------------------------------------------------------------*/
for (attr = qs_get_attr(doc,node);
- attr && color == NULL;
+ 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',"color", name) && value && *value) {
- color = apr_pstrdup(doc->buf.pool, value);
+ attr_color = apr_pstrdup(doc->buf.pool, value);
break;
}
else if (STRCASEEQ('s','S',"size", name)) {
/*----------------------------------------------------------------------*/
/* ignore */
}
+ else if (STRCASEEQ('s','S',"style", name) && value && *value) {
+ attr_style = value;
+ }
}
- if (color) {
+ if (IS_CSS_ON(chtml40->entryp)) {
+ css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
+ if (style) {
+ css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
+ css_property_t *cur;
+ for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
+ if (cur->value && *cur->value) {
+ attr_color = apr_pstrdup(doc->pool, cur->value);
+ }
+ }
+ }
+ }
+ if (attr_color) {
W_L("<font color=\"");
- W_V(color);
+ W_V(attr_color);
W_L("\">");
- chtml40->font_flag++;
+ chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(*flg));
+ flg->with_font_flag = 1;
+ node->userData = flg;
+ }
+ else {
+ node->userData = NULL;
}
return chtml40->out;
}
* @return The conversion result is returned.
*/
static char *
-s_chtml40_end_font_tag(void *pdoc, Node *UNUSED(child))
+s_chtml40_end_font_tag(void *pdoc, Node *node)
{
chtml40_t *chtml40;
Doc *doc;
doc = chtml40->doc;
r = doc->r;
- if (chtml40->font_flag) {
+ chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
+ if (flg && flg->with_font_flag) {
W_L("</font>");
- chtml40->font_flag--;
+ }
+ if (IS_CSS_ON(chtml40->entryp)) {
+ chxj_css_pop_prop_list(chtml40->css_prop_stack);
}
return chtml40->out;
void test_chtml40_body_tag_with_css_005();
void test_chtml40_body_tag_with_css_006();
void test_chtml40_body_tag_with_css_007();
+
+void test_chtml40_font_tag_with_css_001();
+void test_chtml40_font_tag_with_css_002();
/* pend */
int
CU_add_test(chtml40_suite, "test body with css 005", test_chtml40_body_tag_with_css_005);
CU_add_test(chtml40_suite, "test body with css 006", test_chtml40_body_tag_with_css_006);
CU_add_test(chtml40_suite, "test body with css 007", test_chtml40_body_tag_with_css_007);
+
+ CU_add_test(chtml40_suite, "test font with css 001", test_chtml40_font_tag_with_css_001);
+ CU_add_test(chtml40_suite, "test font with css 002", test_chtml40_font_tag_with_css_002);
/* aend */
CU_basic_run_tests();
#undef TEST_STRING
#undef RESULT_STRING
}
+
+
+
+/*===========================================================================*/
+/* font tag with CSS */
+/*===========================================================================*/
+char *test_chxj_serf_get065(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"
+ "font { color:#ff0000 }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml40_font_tag_with_css_001()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><font>あいう</font></html>"
+#define RESULT_STRING "<html><head></head><font color=\"#ff0000\">あいう</font></html>"
+ 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_get065;
+ 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_chtml40(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ 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_chtml40_font_tag_with_css_002()
+{
+#define TEST_STRING "<html><head>" \
+ "</head><font style=\"color:#ff0000;\">あいう</font></html>"
+#define RESULT_STRING "<html><head></head><font color=\"#ff0000\">あいう</font></html>"
+ 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_get065;
+ 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_chtml40(&r, &spec, tmp, destlen, &destlen, &entry, &cookie);
+ ret = chxj_rencoding(&r, ret, &destlen);
+ fprintf(stderr, "actual:[%s]\n", ret);
+ fprintf(stderr, "expect:[%s]\n", RESULT_STRING);
+ 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
*/