Another quick win on ownership.
This commit is contained in:
27
src/form.cc
27
src/form.cc
@ -91,7 +91,7 @@ class DilloHtmlForm {
|
|||||||
bool showing_hiddens;
|
bool showing_hiddens;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
void eventHandler(Resource *resource, EventButton *event);
|
void eventHandler(Resource *resource, EventButton *event);
|
||||||
DilloUrl *buildQueryUrl(DilloHtmlInput *active_input);
|
std::unique_ptr< DilloUrl > buildQueryUrl(DilloHtmlInput *active_input);
|
||||||
std::optional< std::string > buildQueryData(DilloHtmlInput *active_submit);
|
std::optional< std::string > buildQueryData(DilloHtmlInput *active_submit);
|
||||||
char *makeMultipartBoundary(iconv_t char_encoder,
|
char *makeMultipartBoundary(iconv_t char_encoder,
|
||||||
DilloHtmlInput *active_submit);
|
DilloHtmlInput *active_submit);
|
||||||
@ -1060,20 +1060,19 @@ void DilloHtmlForm::submit(DilloHtmlInput *active_input, EventButton *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DilloUrl *url = buildQueryUrl(active_input);
|
auto url = buildQueryUrl(active_input);
|
||||||
if (url) {
|
if (url) {
|
||||||
if (event && event->button == 2) {
|
if (event && event->button == 2) {
|
||||||
if (prefs.middle_click_opens_new_tab) {
|
if (prefs.middle_click_opens_new_tab) {
|
||||||
int focus = prefs.focus_new_tab ? 1 : 0;
|
int focus = prefs.focus_new_tab ? 1 : 0;
|
||||||
if (event->state == SHIFT_MASK) focus = !focus;
|
if (event->state == SHIFT_MASK) focus = !focus;
|
||||||
a_UIcmd_open_url_nt(html->bw, url, focus);
|
a_UIcmd_open_url_nt(html->bw, url.get(), focus);
|
||||||
} else {
|
} else {
|
||||||
a_UIcmd_open_url_nw(html->bw, url);
|
a_UIcmd_open_url_nw(html->bw, url.get());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a_UIcmd_open_url(html->bw, url);
|
a_UIcmd_open_url(html->bw, url.get());
|
||||||
}
|
}
|
||||||
delete url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,9 +1080,9 @@ void DilloHtmlForm::submit(DilloHtmlInput *active_input, EventButton *event)
|
|||||||
* Build a new query URL.
|
* Build a new query URL.
|
||||||
* (Called by submit())
|
* (Called by submit())
|
||||||
*/
|
*/
|
||||||
DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
|
std::unique_ptr< DilloUrl > DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
|
||||||
{
|
{
|
||||||
DilloUrl *new_url = NULL;
|
std::unique_ptr< DilloUrl > new_url;
|
||||||
|
|
||||||
if ((method == DILLO_HTML_METHOD_GET) ||
|
if ((method == DILLO_HTML_METHOD_GET) ||
|
||||||
(method == DILLO_HTML_METHOD_POST)) {
|
(method == DILLO_HTML_METHOD_POST)) {
|
||||||
@ -1107,12 +1106,12 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
|
|||||||
char *action_str = dStrdup(URL_STR(action));
|
char *action_str = dStrdup(URL_STR(action));
|
||||||
|
|
||||||
if (method == DILLO_HTML_METHOD_POST) {
|
if (method == DILLO_HTML_METHOD_POST) {
|
||||||
new_url = a_Url_new(action_str, NULL).release();
|
new_url = a_Url_new(action_str, NULL);
|
||||||
/* new_url keeps the dStr and sets DataStr to NULL */
|
/* new_url keeps the dStr and sets DataStr to NULL */
|
||||||
a_Url_set_data(new_url, DataStr);
|
a_Url_set_data(new_url.get(), DataStr);
|
||||||
a_Url_set_flags(new_url, URL_FLAGS(new_url) | URL_Post);
|
a_Url_set_flags(new_url.get(), URL_FLAGS(new_url.get()) | URL_Post);
|
||||||
if (content_type == DILLO_HTML_ENC_MULTIPART)
|
if (content_type == DILLO_HTML_ENC_MULTIPART)
|
||||||
a_Url_set_flags(new_url, URL_FLAGS(new_url) | URL_MultipartEnc);
|
a_Url_set_flags(new_url.get(), URL_FLAGS(new_url.get()) | URL_MultipartEnc);
|
||||||
} else {
|
} else {
|
||||||
/* remove <fragment> and <query> sections if present */
|
/* remove <fragment> and <query> sections if present */
|
||||||
char *url_str, *p;
|
char *url_str, *p;
|
||||||
@ -1122,8 +1121,8 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
|
|||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
url_str = dStrconcat(action_str, "?", DataStr.c_str(), NULL);
|
url_str = dStrconcat(action_str, "?", DataStr.c_str(), NULL);
|
||||||
new_url = a_Url_new(url_str, NULL).release();
|
new_url = a_Url_new(url_str, NULL);
|
||||||
a_Url_set_flags(new_url, URL_FLAGS(new_url) | URL_Get);
|
a_Url_set_flags(new_url.get(), URL_FLAGS(new_url.get()) | URL_Get);
|
||||||
dFree(url_str);
|
dFree(url_str);
|
||||||
}
|
}
|
||||||
dFree(action_str);
|
dFree(action_str);
|
||||||
|
|||||||
Reference in New Issue
Block a user