diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/auth.c | 4 | ||||
-rw-r--r-- | src/form.cc | 42 | ||||
-rw-r--r-- | src/form.hh | 1 | ||||
-rw-r--r-- | src/html.cc | 13 | ||||
-rw-r--r-- | src/html.hh | 1 | ||||
-rw-r--r-- | src/menu.cc | 33 | ||||
-rw-r--r-- | src/menu.hh | 2 | ||||
-rw-r--r-- | src/uicmd.cc | 5 | ||||
-rw-r--r-- | src/uicmd.hh | 3 |
9 files changed, 90 insertions, 14 deletions
@@ -234,7 +234,7 @@ static int Auth_parse_token_value(AuthParse_t *auth_parse, char **auth) /* is this value the realm? */ set_realm = auth_parse->realm == NULL && - strncasecmp(realm_token,token,token_size) == 0 && + dStrncasecmp(realm_token,token,token_size) == 0 && strlen(realm_token) == token_size; return Auth_parse_quoted_string(auth_parse, set_realm, auth); @@ -275,7 +275,7 @@ static void Auth_parse_auth_basic(AuthParse_t *auth_parse, char **auth) static void Auth_parse_auth(AuthParse_t *auth_parse, char *auth) { _MSG("auth.c: Auth_parse_auth: auth = '%s'\n", auth); - if (strncasecmp(auth, "Basic ", 6) == 0) { + if (dStrncasecmp(auth, "Basic ", 6) == 0) { auth += 6; Auth_parse_auth_basic(auth_parse, &auth); } else { diff --git a/src/form.cc b/src/form.cc index c442c017..2f8b320a 100644 --- a/src/form.cc +++ b/src/form.cc @@ -75,6 +75,7 @@ class DilloHtmlForm { friend class DilloHtmlInput; DilloHtml *html; + bool showing_hiddens; void eventHandler(Resource *resource, EventButton *event); DilloUrl *buildQueryUrl(DilloHtmlInput *active_input); Dstr *buildQueryData(DilloHtmlInput *active_submit); @@ -114,6 +115,7 @@ public: DilloHtmlInput *getRadioInput (const char *name); void submit(DilloHtmlInput *active_input, EventButton *event); void reset (); + void display_hiddens(bool display); void addInput(DilloHtmlInput *input, DilloHtmlInputType type); }; @@ -216,6 +218,11 @@ void a_Html_form_reset2(void *vform) ((DilloHtmlForm *)vform)->reset(); } +void a_Html_form_display_hiddens2(void *vform, bool display) +{ + ((DilloHtmlForm *)vform)->display_hiddens(display); +} + /* * Form parsing functions */ @@ -438,7 +445,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) inp_type = DILLO_HTML_INPUT_PASSWORD; attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); - resource = factory->createEntryResource (size, true); + resource = factory->createEntryResource (size, true, NULL); init_str = value; } else if (!dStrcasecmp(type, "checkbox")) { inp_type = DILLO_HTML_INPUT_CHECKBOX; @@ -457,6 +464,8 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) } else if (!dStrcasecmp(type, "hidden")) { inp_type = DILLO_HTML_INPUT_HIDDEN; init_str = value; + int size = Html_input_get_size(html, NULL); + resource = factory->createEntryResource(size, false, name); } else if (!dStrcasecmp(type, "submit")) { inp_type = DILLO_HTML_INPUT_SUBMIT; init_str = (value) ? value : dStrdup("submit"); @@ -514,7 +523,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) inp_type = DILLO_HTML_INPUT_TEXT; attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); - resource = factory->createEntryResource(size, false); + resource = factory->createEntryResource(size, false, NULL); init_str = value; } else { /* Unknown input type */ @@ -531,6 +540,10 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) if (embed != NULL && inp_type != DILLO_HTML_INPUT_IMAGE && inp_type != DILLO_HTML_INPUT_UNKNOWN) { + if (inp_type == DILLO_HTML_INPUT_HIDDEN) { + /* TODO Perhaps do this with access to current form setting */ + embed->setDisplayed(false); + } if (inp_type == DILLO_HTML_INPUT_TEXT || inp_type == DILLO_HTML_INPUT_PASSWORD) { if (a_Html_get_attr(html, tag, tagsize, "readonly")) @@ -587,7 +600,7 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize) DW2TB(html->dw)->addText(attrbuf, html->styleEngine->wordStyle ()); ResourceFactory *factory = HT2LT(html)->getResourceFactory(); - EntryResource *entryResource = factory->createEntryResource (20, false); + EntryResource *entryResource = factory->createEntryResource (20,false,NULL); embed = new Embed (entryResource); Html_add_input(html, DILLO_HTML_INPUT_INDEX, embed, NULL, NULL, FALSE); @@ -934,6 +947,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2, inputs = new misc::SimpleVector <DilloHtmlInput*> (4); num_entry_fields = 0; num_submit_buttons = 0; + showing_hiddens = false; form_receiver = new DilloHtmlReceiver (this); } @@ -955,7 +969,7 @@ void DilloHtmlForm::eventHandler(Resource *resource, EventButton *event) { MSG("DilloHtmlForm::eventHandler\n"); if (event && (event->button == 3)) { - a_UIcmd_form_popup(html->bw, html->page_url, this); + a_UIcmd_form_popup(html->bw, html->page_url, this, showing_hiddens); } else { DilloHtmlInput *input = getInput(resource); if (input) { @@ -1438,6 +1452,21 @@ void DilloHtmlForm::reset () } /* + * Show/hide "hidden" form controls + */ +void DilloHtmlForm::display_hiddens(bool display) +{ + int size = inputs->size(); + for (int i = 0; i < size; i++) { + DilloHtmlInput *input = inputs->get(i); + if (input->type == DILLO_HTML_INPUT_HIDDEN) { + input->embed->setDisplayed(display); + } + } + showing_hiddens = display; +} + +/* * Add a new input. */ void DilloHtmlForm::addInput(DilloHtmlInput *input, DilloHtmlInputType type) @@ -1660,6 +1689,7 @@ void DilloHtmlInput::appendValuesTo(Dlist *values, bool is_active_submit) case DILLO_HTML_INPUT_TEXT: case DILLO_HTML_INPUT_PASSWORD: case DILLO_HTML_INPUT_INDEX: + case DILLO_HTML_INPUT_HIDDEN: { EntryResource *entryres = (EntryResource*)embed->getResource(); dList_append(values, dStr_new(entryres->getText())); @@ -1687,9 +1717,6 @@ void DilloHtmlInput::appendValuesTo(Dlist *values, bool is_active_submit) if (is_active_submit) dList_append(values, dStr_new(init_str)); break; - case DILLO_HTML_INPUT_HIDDEN: - dList_append(values, dStr_new(init_str)); - break; case DILLO_HTML_INPUT_SELECT: case DILLO_HTML_INPUT_SEL_LIST: { @@ -1738,6 +1765,7 @@ void DilloHtmlInput::reset () case DILLO_HTML_INPUT_TEXT: case DILLO_HTML_INPUT_PASSWORD: case DILLO_HTML_INPUT_INDEX: + case DILLO_HTML_INPUT_HIDDEN: { EntryResource *entryres = (EntryResource*)embed->getResource(); entryres->setText(init_str ? init_str : ""); diff --git a/src/form.hh b/src/form.hh index 910efe20..fd48a18d 100644 --- a/src/form.hh +++ b/src/form.hh @@ -40,6 +40,7 @@ void a_Html_form_delete(DilloHtmlForm* form); void a_Html_input_delete(DilloHtmlInput* input); void a_Html_form_submit2(void *v_form); void a_Html_form_reset2(void *v_form); +void a_Html_form_display_hiddens2(void *v_form, bool display); /* diff --git a/src/html.cc b/src/html.cc index 5b70ecde..2c348fc8 100644 --- a/src/html.cc +++ b/src/html.cc @@ -254,6 +254,19 @@ void a_Html_form_reset(void *v_html, void *v_form) } /* + * Used by the "Show/Hide hiddens" form menuitem. + */ +void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display) +{ + DilloHtml *html = (DilloHtml*)v_html; + + if (Html_contains_form(html, v_form)) { + /* it's still valid */ + a_Html_form_display_hiddens2(v_form, (display != 0)); + } +} + +/* * Set the URL data for image maps. */ static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y) diff --git a/src/html.hh b/src/html.hh index b742261c..5b18c1a8 100644 --- a/src/html.hh +++ b/src/html.hh @@ -13,6 +13,7 @@ extern "C" { void a_Html_load_images(void *v_html, DilloUrl *pattern); void a_Html_form_submit(void *v_html, void *v_form); void a_Html_form_reset(void *v_html, void *v_form); +void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display); #ifdef __cplusplus } diff --git a/src/menu.cc b/src/menu.cc index a95ed0ec..002d970f 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -250,6 +250,29 @@ static void Menu_form_reset_cb(Widget*, void *v_form) } } +/* + * Toggle display of 'hidden' form controls. + */ +static void Menu_form_hiddens_cb(Widget *w, void *user_data) +{ + void *v_form = w->parent()->user_data(); + bool visible = *((bool *) user_data); + + if (popup_bw && popup_bw->Docs) { + if (dList_find_custom(popup_bw->PageUrls, popup_url, + (dCompareFunc)a_Url_cmp)){ + /* HTML page is still there */ + int n = dList_length(popup_bw->Docs); + if (n == 1) { + a_Html_form_display_hiddens(dList_nth_data(popup_bw->Docs, 0), + v_form, !visible); + } else if (n > 1) { + MSG ("Menu_form_hiddens_cb multiple Docs not implemented\n"); + } + } + } +} + /* * Validate URL with the W3C */ @@ -493,9 +516,11 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, * Form popup menu (construction & popup) */ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, - void *formptr) + void *formptr, bool_t hidvis) { static PopupMenu *pm = 0; + static Item *hiddens_item = 0; + static bool hiddens_visible; popup_bw = bw; a_Url_free(popup_url); @@ -507,10 +532,16 @@ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, i->callback(Menu_form_submit_cb); pm->add(i = new Item("Reset form")); i->callback(Menu_form_reset_cb); + pm->add(hiddens_item = new Item("")); + hiddens_item->callback(Menu_form_hiddens_cb); + hiddens_item->user_data(&hiddens_visible); pm->type(PopupMenu::POPUP123); } pm->user_data(formptr); + hiddens_visible = hidvis; + hiddens_item->label(hiddens_visible ? "Hide hiddens": "Show hiddens"); + a_Timeout_add(0.0, Menu_popup_cb, (void *)pm); } diff --git a/src/menu.hh b/src/menu.hh index 2b30e47d..be20bc49 100644 --- a/src/menu.hh +++ b/src/menu.hh @@ -13,7 +13,7 @@ void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url); void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, bool_t loaded_img, DilloUrl *link_url); void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, - void *vform); + void *vform, bool_t showing_hiddens); void a_Menu_file_popup(BrowserWindow *bw, void *v_wid); void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url); void a_Menu_history_popup(BrowserWindow *bw, int direction); diff --git a/src/uicmd.cc b/src/uicmd.cc index f8869129..654f1277 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -668,9 +668,10 @@ void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, /* * Pop up the form menu */ -void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform) +void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform, + bool_t showing_hiddens) { - a_Menu_form_popup((BrowserWindow*)vbw, url, vform); + a_Menu_form_popup((BrowserWindow*)vbw, url, vform, showing_hiddens); } /* diff --git a/src/uicmd.hh b/src/uicmd.hh index 3b5dc27e..6adb43ad 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -41,7 +41,8 @@ void a_UIcmd_page_popup(void *vbw, const DilloUrl *url, void a_UIcmd_link_popup(void *vbw, const DilloUrl *url); void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, DilloUrl *link_url); -void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform); +void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform, + bool_t showing_hiddens); void a_UIcmd_file_popup(void *vbw, void *v_wid); void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr); void a_UIcmd_view_page_source(const DilloUrl *url); |