Improve parameters handling
There's no need to reload all parameters each time a new url is loaded, instead set only custom parameters and restore those to defaults when needed.
This commit is contained in:
parent
b115434720
commit
745a319baf
1 changed files with 17 additions and 4 deletions
21
surf.c
21
surf.c
|
@ -636,18 +636,32 @@ cookiepolicy_set(const WebKitCookieAcceptPolicy p)
|
||||||
void
|
void
|
||||||
seturiparameters(Client *c, const char *uri)
|
seturiparameters(Client *c, const char *uri)
|
||||||
{
|
{
|
||||||
|
Parameter *newconfig = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < LENGTH(uriparams); ++i) {
|
for (i = 0; i < LENGTH(uriparams); ++i) {
|
||||||
if (uriparams[i].uri &&
|
if (uriparams[i].uri &&
|
||||||
!regexec(&(uriparams[i].re), uri, 0, NULL, 0)) {
|
!regexec(&(uriparams[i].re), uri, 0, NULL, 0)) {
|
||||||
curconfig = uriparams[i].config;
|
newconfig = uriparams[i].config;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ParameterLast; ++i)
|
if (!newconfig)
|
||||||
setparameter(c, 0, i, &curconfig[i].val);
|
newconfig = defconfig;
|
||||||
|
if (newconfig == curconfig)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < ParameterLast; ++i) {
|
||||||
|
if (defconfig[i].force)
|
||||||
|
continue;
|
||||||
|
if (newconfig[i].force)
|
||||||
|
setparameter(c, 0, i, &newconfig[i].val);
|
||||||
|
else if (curconfig[i].force)
|
||||||
|
setparameter(c, 0, i, &defconfig[i].val);
|
||||||
|
}
|
||||||
|
|
||||||
|
curconfig = newconfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1350,7 +1364,6 @@ loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c)
|
||||||
|
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case WEBKIT_LOAD_STARTED:
|
case WEBKIT_LOAD_STARTED:
|
||||||
curconfig = defconfig;
|
|
||||||
setatom(c, AtomUri, title);
|
setatom(c, AtomUri, title);
|
||||||
c->title = title;
|
c->title = title;
|
||||||
c->https = c->insecure = 0;
|
c->https = c->insecure = 0;
|
||||||
|
|
Loading…
Reference in a new issue