OSDN Git Service

* Added background-color property to div tag for au XHTML converter.
authorAtsushi Konno <konn@users.sourceforge.jp>
Sat, 15 Nov 2008 17:42:01 +0000 (02:42 +0900)
committerAtsushi Konno <konn@users.sourceforge.jp>
Sat, 15 Nov 2008 17:42:01 +0000 (02:42 +0900)
  * Added background property to div tag for au XHTML converter.

src/chxj_xhtml_mobile_1_0.c
test/chxj_xhtml_mobile_1_0/test_chxj_xhtml_mobile_1_0.c

index a7657ea..2c5cc2d 100644 (file)
@@ -3566,6 +3566,7 @@ s_xhtml_1_0_start_div_tag(void *pdoc, Node *node)
   char        *attr_wap_marquee_dir   = NULL;
   char        *attr_wap_marquee_loop  = NULL;
   char        *attr_color             = NULL;
+  char        *attr_bgcolor           = NULL;
   char        *attr_font_size         = NULL;
 
   for (attr = qs_get_attr(doc,node);
@@ -3594,6 +3595,8 @@ s_xhtml_1_0_start_div_tag(void *pdoc, Node *node)
       css_property_t *color_prop             = chxj_css_get_property_value(doc, style, "color");
       css_property_t *text_align_prop        = chxj_css_get_property_value(doc, style, "text-align");
       css_property_t *font_size_prop         = chxj_css_get_property_value(doc, style, "font-size");
+      css_property_t *background_color_prop  = chxj_css_get_property_value(doc, style, "background-color");
+      css_property_t *background_prop        = chxj_css_get_property_value(doc, style, "background");
 
       css_property_t *cur;
       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
@@ -3606,6 +3609,17 @@ s_xhtml_1_0_start_div_tag(void *pdoc, Node *node)
           attr_decoration = apr_pstrdup(doc->pool, cur->value);
         }
       }
+      for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
+        attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
+        attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
+      }
+      for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
+        char *ss = strchr(cur->value, '#');
+        if (ss) {
+          attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
+          attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
+        }
+      }
       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
         attr_color = apr_pstrdup(doc->pool, cur->value);
       }
@@ -3647,7 +3661,15 @@ s_xhtml_1_0_start_div_tag(void *pdoc, Node *node)
     }
   }  
   W_L("<div");
-  if (attr_align || attr_display || attr_decoration || attr_wap_marquee_style || attr_wap_marquee_dir || attr_wap_marquee_loop || attr_color || attr_font_size) {
+  if (attr_align
+      || attr_display
+      || attr_decoration
+      || attr_wap_marquee_style
+      || attr_wap_marquee_dir
+      || attr_wap_marquee_loop
+      || attr_color
+      || attr_bgcolor
+      || attr_font_size) {
     W_L(" style=\"");
     if (attr_align) {
       W_L("text-align:");
@@ -3684,6 +3706,11 @@ s_xhtml_1_0_start_div_tag(void *pdoc, Node *node)
       W_V(attr_color);
       W_L(";");
     }
+    if (attr_bgcolor) {
+      W_L("background-color:");
+      W_V(attr_bgcolor);
+      W_L(";");
+    }
     if (attr_font_size) {
       W_L("font-size:");
       W_V(attr_font_size);
index 2f60ea0..6d8be9f 100644 (file)
@@ -34,6 +34,7 @@
 #include "chxj_apache.c"
 #include "chxj_dbm.c"
 #include "chxj_str_util.c"
+#include "chxj_dump_string.c"
 #include <iconv.h>
 #include "chxj_serf.h"
 #include "chxj_css.h"
@@ -744,6 +745,8 @@ void test_xhtml_div_tag_with_css_039();
 void test_xhtml_div_tag_with_css_040();
 void test_xhtml_div_tag_with_css_041();
 void test_xhtml_div_tag_with_css_042();
+void test_xhtml_div_tag_with_css_043();
+void test_xhtml_div_tag_with_css_044();
 
 void test_xhtml_dt_tag_with_css_001();
 void test_xhtml_dt_tag_with_css_002();
@@ -1715,6 +1718,8 @@ main()
   CU_add_test(xhtml_suite, "test div with css 040",                              test_xhtml_div_tag_with_css_040);
   CU_add_test(xhtml_suite, "test div with css 041",                              test_xhtml_div_tag_with_css_041);
   CU_add_test(xhtml_suite, "test div with css 042",                              test_xhtml_div_tag_with_css_042);
+  CU_add_test(xhtml_suite, "test div with css 043",                              test_xhtml_div_tag_with_css_043);
+  CU_add_test(xhtml_suite, "test div with css 044",                              test_xhtml_div_tag_with_css_044);
 
   CU_add_test(xhtml_suite, "test dt with css 001",                              test_xhtml_dt_tag_with_css_001);
   CU_add_test(xhtml_suite, "test dt with css 002",                              test_xhtml_dt_tag_with_css_002);
@@ -4116,8 +4121,11 @@ void test_xhtml_form_tag_005()
 }
 void test_xhtml_form_tag_006() 
 {
-#define  TEST_STRING "<form action></form>"
-#define  RESULT_STRING "<form action=\"\"><input type=\"hidden\" name=\"_chxj_cc\" value=\"test_cookie_id\"></form>"
+#define  TEST_STRING "<html><form action></form></html>"
+#define  RESULT_STRING "<?xml version=\"1.0\" encoding=\"Windows-31J\"?>" \
+                       "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.0//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd\">" \
+                       "<html xmlns=\"http://www.w3.org/1999/xhtml\">" \
+                       "<form action=\"\"></form></html>"
   char  *ret;
   char  *tmp;
   device_table spec;
@@ -4204,7 +4212,7 @@ void test_xhtml_form_tag_008()
 void test_xhtml_form_tag_009() 
 {
 #define  TEST_STRING "<form method=\"post\" action=\"hogehoge\"></form>"
-#define  RESULT_STRING "<form action=\"hogehoge\" method=\"post\"><input type=\"hidden\" name=\"_chxj_cc\" value=\"test_cookie_id\"></form>"
+#define  RESULT_STRING "<form action=\"hogehoge\" method=\"post\"></form>"
   char  *ret;
   char  *tmp;
   device_table spec;
@@ -23420,6 +23428,95 @@ void test_xhtml_div_tag_with_css_042()
 #undef RESULT_STRING
 }
 
+char *test_chxj_serf_get141(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"
+                     "div     { background:#ffffff; }\n";
+
+  *len = strlen(css);
+  call_check = 1;
+  return css;
+}
+void test_xhtml_div_tag_with_css_043()
+{
+#define  TEST_STRING "<html><head><link rel=\"stylesheet\" href=\"http://localhost/a.css\"  type=\"text/css\" />" \
+                     "</head><body><div>あいう</div></body></html>"
+#define  RESULT_STRING "<?xml version=\"1.0\" encoding=\"Windows-31J\"?>" \
+                       "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.0//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd\">" \
+                       "<html xmlns=\"http://www.w3.org/1999/xhtml\">" \
+                       "<head></head><body><div style=\"background-color:#ffffff;\">あいう</div></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_get141;
+  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);
+  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_xhtml_div_tag_with_css_044()
+{
+#define  TEST_STRING "<html><head>" \
+                     "</head><body><div style=\"background:#ffffff;\">あいう</div></body></html>"
+#define  RESULT_STRING "<?xml version=\"1.0\" encoding=\"Windows-31J\"?>" \
+                       "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.0//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd\">" \
+                       "<html xmlns=\"http://www.w3.org/1999/xhtml\">" \
+                       "<head></head><body><div style=\"background-color:#ffffff;\">あいう</div></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_get141;
+  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);
+  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
+}
 
 /*===========================================================================*/
 /* dt tag with CSS                                                           */