[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: <button> on forms



At Tue, 01 Jul 2008 20:48:22 +0800,
jidanni@xxxxxxxxxxx wrote:
> 
> Can anybody submit Wordpress comments?
> E.g., on http://pinyin.info/news/2006/chinese-literacy/
> there is
> <button name="submit" type="submit" id="submit" tabindex="5">Submit Comment</button>
> 
> Lynx and firefox makes it clickable, but emacs-w3m and I am afraid w3m
> too, just show it as text.
> 

Try the attached patch to the current CVS HEAD of the w3m source tree.

-- 
Tetsurou Okazaki

Obtained from: http://www.sic.med.tohoku.ac.jp/~satodai/w3m-dev/200203.month/3100.html

Index: tagtable.tab
===================================================================
RCS file: /cvsroot/w3m/w3m/tagtable.tab,v
retrieving revision 1.12
diff -u -r1.12 tagtable.tab
--- tagtable.tab	10 Dec 2006 11:06:12 -0000	1.12
+++ tagtable.tab	2 Jul 2008 03:21:05 -0000
@@ -87,6 +87,8 @@
 form		HTML_FORM
 /form		HTML_N_FORM
 input		HTML_INPUT
+button		HTML_BUTTON
+/button		HTML_N_BUTTON
 textarea	HTML_TEXTAREA
 /textarea	HTML_N_TEXTAREA
 select		HTML_SELECT
Index: table.c
===================================================================
RCS file: /cvsroot/w3m/w3m/table.c,v
retrieving revision 1.55
diff -u -r1.55 table.c
--- table.c	23 May 2007 13:07:44 -0000	1.55
+++ table.c	2 Jul 2008 03:21:05 -0000
@@ -2873,6 +2873,14 @@
 	tmp = process_input(tag);
 	feed_table1(tbl, tmp, mode, width);
 	break;
+    case HTML_BUTTON:
+	tmp = process_button(tag);
+	feed_table1(tbl, tmp, mode, width);
+	break;
+    case HTML_N_BUTTON:
+	tmp = process_n_button();
+	feed_table1(tbl, tmp, mode, width);
+	break;
     case HTML_SELECT:
 	tmp = process_select(tag);
 	if (tmp)
Index: proto.h
===================================================================
RCS file: /cvsroot/w3m/w3m/proto.h,v
retrieving revision 1.101
diff -u -r1.101 proto.h
--- proto.h	7 Apr 2006 13:21:12 -0000	1.101
+++ proto.h	2 Jul 2008 03:21:05 -0000
@@ -203,6 +203,8 @@
 extern Str process_img(struct parsed_tag *tag, int width);
 extern Str process_anchor(struct parsed_tag *tag, char *tagbuf);
 extern Str process_input(struct parsed_tag *tag);
+extern Str process_button(struct parsed_tag *tag);
+extern Str process_n_button(void);
 extern Str process_select(struct parsed_tag *tag);
 extern Str process_n_select(void);
 extern void feed_select(char *str);
Index: html.h
===================================================================
RCS file: /cvsroot/w3m/w3m/html.h,v
retrieving revision 1.29
diff -u -r1.29 html.h
--- html.h	23 May 2007 12:01:43 -0000	1.29
+++ html.h	2 Jul 2008 03:21:05 -0000
@@ -202,6 +202,8 @@
 #define HTML_N_I	110
 #define HTML_STRONG	111
 #define HTML_N_STRONG	112
+#define HTML_BUTTON	113
+#define HTML_N_BUTTON	114
 
    /* pseudo tag */
 #define HTML_SELECT_INT     120
Index: html.c
===================================================================
RCS file: /cvsroot/w3m/w3m/html.c,v
retrieving revision 1.30
diff -u -r1.30 html.c
--- html.c	19 Apr 2007 12:00:38 -0000	1.30
+++ html.c	2 Jul 2008 03:21:05 -0000
@@ -56,6 +56,9 @@
     ATTR_CORE
 };
 #define MAXA_INPUT      MAXA_CORE + 12
+unsigned char ALST_BUTTON[] =
+    { ATTR_TYPE, ATTR_VALUE, ATTR_NAME, ATTR_CORE };
+#define MAXA_BUTTON      MAXA_CORE + 3
 unsigned char ALST_TEXTAREA[] =
     { ATTR_COLS, ATTR_ROWS, ATTR_NAME, ATTR_READONLY, ATTR_CORE };
 #define MAXA_TEXTAREA   MAXA_CORE + 4
@@ -235,8 +238,8 @@
     {"/i", NULL, 0, TFLG_END},	/*  110 HTML_N_I */
     {"strong", NULL, 0, 0},		/* 111 HTML_STRONG */
     {"/strong", NULL, 0, TFLG_END},	/* 112 HTML_N_STRONG */
-    {NULL, NULL, 0, 0},		/* 113 Undefined       */
-    {NULL, NULL, 0, 0},		/* 114 Undefined       */
+    {"button", ALST_BUTTON, MAXA_BUTTON, 0},		/* 113 HTML_BUTTON       */
+    {"/button", NULL, 0, TFLG_END},		/* 114 HTML_N_BUTTON       */
     {NULL, NULL, 0, 0},		/* 115 Undefined       */
     {NULL, NULL, 0, 0},		/* 116 Undefined       */
     {NULL, NULL, 0, 0},		/* 117 Undefined       */
Index: file.c
===================================================================
RCS file: /cvsroot/w3m/w3m/file.c,v
retrieving revision 1.254
diff -u -r1.254 file.c
--- file.c	23 May 2007 15:06:05 -0000	1.254
+++ file.c	2 Jul 2008 03:21:06 -0000
@@ -3704,6 +3704,63 @@
 }
 
 Str
+process_button(struct parsed_tag *tag)
+{
+    Str tmp = NULL;
+    char *p, *q, *r, *qq = NULL;
+    int qlen, v;
+
+    if (cur_form_id < 0) {
+	char *s = "<form_int method=internal action=none>";
+	tmp = process_form(parse_tag(&s, TRUE));
+    }
+    if (tmp == NULL)
+	tmp = Strnew();
+
+    p = "submit";
+    parsedtag_get_value(tag, ATTR_TYPE, &p);
+    q = NULL;
+    parsedtag_get_value(tag, ATTR_VALUE, &q);
+    r = "";
+    parsedtag_get_value(tag, ATTR_NAME, &r);
+
+    v = formtype(p);
+    if (v == FORM_UNKNOWN)
+	return NULL;
+
+    if (!q) {
+	switch (v) {
+	case FORM_INPUT_SUBMIT:
+	case FORM_INPUT_BUTTON:
+	    q = "SUBMIT";
+	    break;
+	case FORM_INPUT_RESET:
+	    q = "RESET";
+	    break;
+	}
+    }
+    if (q) {
+	qq = html_quote(q);
+	qlen = strlen(q);
+    }
+
+    /* Strcat_charp(tmp, "<pre_int>"); */
+    Strcat(tmp, Sprintf("<input_alt hseq=\"%d\" fid=\"%d\" type=%s "
+			"name=\"%s\" value=\"%s\">",
+			cur_hseq++, cur_form_id, p, html_quote(r), qq));
+    return tmp;
+}
+
+Str
+process_n_button(void)
+{
+    Str tmp = Strnew();
+    Strcat_charp(tmp, "</input_alt>");
+    /* Strcat_charp(tmp, "</pre_int>"); */
+    return tmp;
+}
+
+Str
 process_select(struct parsed_tag *tag)
 {
     Str tmp = NULL;
@@ -4927,6 +4984,18 @@
 	if (tmp)
 	    HTMLlineproc1(tmp->ptr, h_env);
 	return 1;
+    case HTML_BUTTON:
+	close_anchor(h_env, obuf);
+	tmp = process_button(tag);
+	if (tmp)
+	    HTMLlineproc1(tmp->ptr, h_env);
+	return 1;
+    case HTML_N_BUTTON:
+	close_anchor(h_env, obuf);
+	tmp = process_n_button();
+	if (tmp)
+	    HTMLlineproc1(tmp->ptr, h_env);
+	return 1;
     case HTML_SELECT:
 	close_anchor(h_env, obuf);
 	tmp = process_select(tag);