summaryrefslogtreecommitdiff
path: root/src/form.cc
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2013-04-20 23:25:34 +0000
committercorvid <corvid@lavabit.com>2013-04-20 23:25:34 +0000
commitb737980795ce2e17e6a143bf4a0e54f65dbb7997 (patch)
tree9994d3688fc47f19de2d732c28e2f658ca4b9b54 /src/form.cc
parentb1823faf24501fce566fde182a5f56217c3b8dcc (diff)
OPTION label attribute
It is said that this is typically only useful when OPTGROUP is working (OPTGROUP gives context, and label will be something shorter than the OPTION's contents). It is also said that browsers don't or didn't tend to use an OPTION's label. *shrugs*
Diffstat (limited to 'src/form.cc')
-rw-r--r--src/form.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/form.cc b/src/form.cc
index 10b4347f..52f777f4 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -198,16 +198,16 @@ public:
class DilloHtmlOption : public DilloHtmlOptbase {
friend class DilloHtmlSelect;
public:
- char *value, *content;
+ char *value, *label, *content;
bool selected, enabled;
- DilloHtmlOption (char *value, bool selected, bool enabled);
+ DilloHtmlOption (char *value, char *label, bool selected, bool enabled);
virtual ~DilloHtmlOption ();
bool isSelected() {return selected;}
bool select() {return (selected = true);}
const char *getValue() {return value ? value : content;}
void setContent(const char *str, int len) {content = dStrndup(str, len);}
void addSelf (SelectionResource *res)
- {res->addItem(content, enabled, selected);}
+ {res->addItem(label ? label : content, enabled, selected);}
};
class DilloHtmlSelect {
@@ -882,11 +882,12 @@ void Html_tag_open_option(DilloHtml *html, const char *tag, int tagsize)
if (input->type == DILLO_HTML_INPUT_SELECT ||
input->type == DILLO_HTML_INPUT_SEL_LIST) {
char *value = a_Html_get_attr_wdef(html, tag, tagsize, "value", NULL);
+ char *label = a_Html_get_attr_wdef(html, tag, tagsize, "label", NULL);
bool selected = (a_Html_get_attr(html, tag, tagsize,"selected") != NULL);
bool enabled = (a_Html_get_attr(html, tag, tagsize, "disabled") == NULL);
DilloHtmlOption *option =
- new DilloHtmlOption (value, selected, enabled);
+ new DilloHtmlOption (value, label, selected, enabled);
input->select->addOpt(option);
}
@@ -1985,11 +1986,11 @@ DilloHtmlOptgroup::~DilloHtmlOptgroup ()
/*
* Constructor
*/
-DilloHtmlOption::DilloHtmlOption (char *value2,
- bool selected2,
+DilloHtmlOption::DilloHtmlOption (char *value2, char *label2, bool selected2,
bool enabled2)
{
value = value2;
+ label = label2;
content = NULL;
selected = selected2;
enabled = enabled2;
@@ -2001,6 +2002,7 @@ DilloHtmlOption::DilloHtmlOption (char *value2,
DilloHtmlOption::~DilloHtmlOption ()
{
dFree(value);
+ dFree(label);
dFree(content);
}