Doc *doc;
request_rec *r;
Attr *attr;
+ char *attr_bgcolor = NULL;
+ char *attr_text = NULL;
+ char *attr_link = NULL;
+ char *attr_style = NULL;
chtml20 = GET_CHTML20(pdoc);
doc = chtml20->doc;
r = doc->r;
- W_L("<body");
/*--------------------------------------------------------------------------*/
/* Get Attributes */
/*--------------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* CHTML 2.0 */
/*----------------------------------------------------------------------*/
- W_L(" bgcolor=\"");
- W_V(value);
- W_L("\"");
+ attr_bgcolor = value;
}
break;
/*----------------------------------------------------------------------*/
/* CHTML 2.0 */
/*----------------------------------------------------------------------*/
- W_L(" text=\"");
- W_V(value);
- W_L("\"");
+ attr_text = value;
+ }
+ break;
+
+ case 's':
+ case 'S':
+ if (strcasecmp(name, "style") == 0 && value && *value != 0) {
+ attr_style = value;
}
break;
/*----------------------------------------------------------------------*/
/* CHTML 2.0 */
/*----------------------------------------------------------------------*/
- W_L(" link=\"");
- W_V(value);
- W_L("\"");
+ attr_link = value;
}
break;
break;
}
}
+ if (IS_CSS_ON(chtml20->entryp)) {
+ css_prop_list_t *style = s_chtml20_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 *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
+ css_property_t *cur;
+ for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
+ if (cur->value && *cur->value) {
+ attr_text = apr_pstrdup(doc->pool, cur->value);
+ }
+ }
+ for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
+ if (cur->value && *cur->value) {
+ attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
+ }
+ }
+ }
+ if (chtml20->style) {
+ css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, chtml20->style);
+ css_selector_t *cur_sel;
+ for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
+ if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
+ css_property_t *cur;
+ for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
+ if (cur->name && strcasecmp(cur->name, "color") == 0) {
+ attr_link = apr_pstrdup(doc->pool, cur->value);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ W_L("<body");
+ if (attr_bgcolor) {
+ W_L(" bgcolor=\"");
+ W_V(attr_bgcolor);
+ W_L("\"");
+ }
+ if (attr_text) {
+ W_L(" text=\"");
+ W_V(attr_text);
+ W_L("\"");
+ }
+ if (attr_link) {
+ W_L(" link=\"");
+ W_V(attr_link);
+ W_L("\"");
+ }
W_L(">");
return chtml20->out;
/**
- * It is a handter who processes the DT tag.
+ * It is a handler who processes the DT tag.
*
* @param pdoc [i/o] The pointer to the CHTML structure at the output
* destination is specified.
/**
- * It is a handter who processes the DT tag.
+ * It is a handler who processes the DT tag.
*
* @param pdoc [i/o] The pointer to the CHTML structure at the output
* destination is specified.
/**
- * It is a handder who processes the DD tag.
+ * It is a handler who processes the DD tag.
*
* @param pdoc [i/o] The pointer to the CHTML structure at the output
* destination is specified.
/**
- * It is a handder who processes the DD tag.
+ * It is a handler who processes the DD tag.
*
* @param pdoc [i/o] The pointer to the CHTML structure at the output
* destination is specified.
/**
- * It is a hanmenuer who processes the MENU tag.
+ * It is a handler who processes the MENU tag.
*
* @param pdoc [i/o] The pointer to the CHTML structure at the output
* destination is specified.
/**
- * It is a hanmenuer who processes the MENU tag.
+ * It is a handler who processes the MENU tag.
*
* @param pdoc [i/o] The pointer to the CHTML structure at the output
* destination is specified.
/**
- * It is a hanplaintexter who processes the PLAINTEXT tag.
+ * It is a handler who processes the PLAINTEXT tag.
*
* @param pdoc [i/o] The pointer to the CHTML structure at the output
* destination is specified.
void test_chtml20_body_tag_with_css_002();
void test_chtml20_body_tag_with_css_003();
void test_chtml20_body_tag_with_css_004();
+void test_chtml20_body_tag_with_css_005();
/* pend */
int
CU_add_test(chtml20_suite, "test body with css 002", test_chtml20_body_tag_with_css_002);
CU_add_test(chtml20_suite, "test body with css 003", test_chtml20_body_tag_with_css_003);
CU_add_test(chtml20_suite, "test body with css 004", test_chtml20_body_tag_with_css_004);
+ CU_add_test(chtml20_suite, "test body with css 005", test_chtml20_body_tag_with_css_005);
/* aend */
CU_basic_run_tests();
tmp = chxj_encoding(&r, TEST_STRING, &destlen);
ret = chxj_convert_chtml20(&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);
#undef TEST_STRING
#undef RESULT_STRING
}
+char *test_chxj_serf_get060(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:link { color:#ff0000 }\n";
+ *len = strlen(css);
+ call_check = 1;
+ return css;
+}
+void test_chtml20_body_tag_with_css_005()
+{
+#define TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\" type=\"text/css\" />" \
+ "</head><body>あいう</body></html>"
+#define RESULT_STRING "<html><head></head><body link=\"#ff0000\">あいう</body></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_get060;
+ 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_chtml20(&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
+}
/*
* vim:ts=2 et
*/