OSDN Git Service

* Added form tag with CSS for CHTML1.0 converter.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Wed, 16 Jul 2008 10:47:07 +0000 (10:47 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Wed, 16 Jul 2008 10:47:07 +0000 (10:47 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/sandbox@2955 1a406e8e-add9-4483-a2c8-d8cac5b7c224

src/chxj_chtml10.c
test/chxj_chtml10/test_chxj_chtml10.c

index 82a828e..f16b8ed 100644 (file)
@@ -2028,17 +2028,18 @@ s_chtml10_end_tr_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml10_start_form_tag(void *pdoc, Node *node) 
 {
-  chtml10_t    *chtml10;
-  Doc          *doc;
-  request_rec  *r;
-  Attr         *attr;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
+  char        *attr_style  = NULL;
+  char        *attr_action = NULL;
+  char        *attr_method = NULL;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  W_L("<form");
-
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
@@ -2054,12 +2055,7 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        value = chxj_encoding_parameter(r, value);
-        value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
-  
-        W_L(" action=\"");
-        W_V(value);
-        W_L("\"");
+        attr_action = value;
       }
       break;
 
@@ -2069,9 +2065,7 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W_L(" method=\"");
-        W_V(value);
-        W_L("\"");
+        attr_method = value;
       }
       break;
 
@@ -2085,11 +2079,33 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
       }
       break;
 
+    case 's':
+    case 'S':
+      if (strcasecmp(name, "style") == 0 && value && *value) {
+        attr_style = value;
+      }
+      break;
+
     default:
       break;
     }
   }
-
+  if (IS_CSS_ON(chtml10->entryp)) {
+    s_chtml10_push_and_get_now_style(pdoc, node, attr_style);
+  }
+  W_L("<form");
+  if (attr_action) {
+    attr_action = chxj_encoding_parameter(r, attr_action);
+    attr_action = chxj_add_cookie_parameter(r, attr_action, chtml10->cookie);
+    W_L(" action=\"");
+    W_V(attr_action);
+    W_L("\"");
+  }
+  if (attr_method) {
+    W_L(" method=\"");
+    W_V(attr_method);
+    W_L("\"");
+  }
   W_L(">");
 
   return chtml10->out;
@@ -2116,6 +2132,9 @@ s_chtml10_end_form_tag(void *pdoc, Node *UNUSED(child))
   r       = doc->r;
 
   W_L("</form>");
+  if (IS_CSS_ON(chtml10->entryp)) {
+    chxj_css_pop_prop_list(chtml10->css_prop_stack);
+  }
 
   return chtml10->out;
 }
index 5ee35dd..5d3b7d7 100644 (file)
@@ -2777,7 +2777,7 @@ void test_chtml10_form_tag_008()
 void test_chtml10_form_tag_009() 
 {
 #define  TEST_STRING "<html><head></head><body><form method=\"post\" action=\"hogehoge\"></form></body></html>"
-#define  RESULT_STRING "<html><head></head><body><form method=\"post\" action=\"hogehoge?_chxj_cc=test_cookie_id\"></form></body></html>"
+#define  RESULT_STRING "<html><head></head><body><form action=\"hogehoge?_chxj_cc=test_cookie_id\" method=\"post\"></form></body></html>"
   char  *ret;
   char  *tmp;
   device_table spec;
@@ -2794,6 +2794,8 @@ void test_chtml10_form_tag_009()
   tmp = chxj_encoding(&r, TEST_STRING, &destlen);
   ret = chxj_convert_chtml10(&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);