OSDN Git Service

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

src/chxj_ixhtml10.c
test/chxj_ixhtml10/test_chxj_ixhtml10.c

index 12ace66..ba98612 100644 (file)
@@ -3308,6 +3308,7 @@ s_ixhtml10_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;
 
   ixhtml10 = GET_IXHTML10(pdoc);
@@ -3340,6 +3341,8 @@ s_ixhtml10_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) {
@@ -3347,6 +3350,17 @@ s_ixhtml10_start_div_tag(void *pdoc, Node *node)
           attr_display = 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 = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
         if (STRCASEEQ('b','B',"blink", cur->value)) {
           attr_decoration = apr_pstrdup(doc->pool, cur->value);
@@ -3393,7 +3407,15 @@ s_ixhtml10_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:");
@@ -3430,6 +3452,11 @@ s_ixhtml10_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 7ff253c..cb0037e 100644 (file)
@@ -960,6 +960,8 @@ void test_ixhtml10_div_tag_with_css_039();
 void test_ixhtml10_div_tag_with_css_040();
 void test_ixhtml10_div_tag_with_css_041();
 void test_ixhtml10_div_tag_with_css_042();
+void test_ixhtml10_div_tag_with_css_043();
+void test_ixhtml10_div_tag_with_css_044();
 
 /* pend */
 
@@ -2030,6 +2032,8 @@ main()
   CU_add_test(ixhtml10_suite, "test div with css 040",                              test_ixhtml10_div_tag_with_css_040);
   CU_add_test(ixhtml10_suite, "test div with css 041",                              test_ixhtml10_div_tag_with_css_041);
   CU_add_test(ixhtml10_suite, "test div with css 042",                              test_ixhtml10_div_tag_with_css_042);
+  CU_add_test(ixhtml10_suite, "test div with css 043",                              test_ixhtml10_div_tag_with_css_043);
+  CU_add_test(ixhtml10_suite, "test div with css 044",                              test_ixhtml10_div_tag_with_css_044);
   /* aend */
 
   CU_basic_run_tests();
@@ -24156,6 +24160,95 @@ void test_ixhtml10_div_tag_with_css_042()
 #undef TEST_STRING
 #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_ixhtml10_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=\"Shift_JIS\" ?>" \
+                       "<!DOCTYPE html PUBLIC \"-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/1.0) 1.0//EN\" \"i-xhtml_4ja_10.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_ixhtml10(&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_ixhtml10_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=\"Shift_JIS\" ?>" \
+                       "<!DOCTYPE html PUBLIC \"-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/1.0) 1.0//EN\" \"i-xhtml_4ja_10.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_ixhtml10(&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
+}