Store modified parameters list

This commit is contained in:
Quentin Rameau 2017-05-21 22:53:56 +02:00
parent a8bf206827
commit a0c3c80ee6

29
surf.c
View file

@ -241,6 +241,7 @@ static GdkDevice *gdkkb;
static char *stylefile; static char *stylefile;
static const char *useragent; static const char *useragent;
static Parameter *curconfig; static Parameter *curconfig;
static int modparams[ParameterLast];
char *argv0; char *argv0;
static ParamName loadtransient[] = { static ParamName loadtransient[] = {
@ -673,41 +674,31 @@ cookiepolicy_set(const WebKitCookieAcceptPolicy p)
void void
seturiparameters(Client *c, const char *uri, ParamName *params) seturiparameters(Client *c, const char *uri, ParamName *params)
{ {
Parameter *config, *newconfig = NULL; Parameter *config, *uriconfig = NULL;
int i, p; int i, p;
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)) {
newconfig = uriparams[i].config; uriconfig = uriparams[i].config;
break; break;
} }
} }
if (!newconfig) curconfig = uriconfig ? uriconfig : defconfig;
newconfig = defconfig;
for (i = 0; (p = params[i]) != ParameterLast; ++i) { for (i = 0; (p = params[i]) != ParameterLast; ++i) {
switch(p) { switch(p) {
default: /* FALLTHROUGH */
if (!(defconfig[p].prio < curconfig[p].prio ||
defconfig[p].prio < modparams[p]))
continue;
case Certificate: case Certificate:
case CookiePolicies: case CookiePolicies:
case Style: case Style:
config = (newconfig[p].prio > defconfig[p].prio) ? setparameter(c, 0, p, &curconfig[p].val);
newconfig : defconfig;
break;
default:
if (newconfig[p].prio > defconfig[p].prio)
config = newconfig;
else if (curconfig[p].prio > defconfig[p].prio)
config = defconfig;
else
continue;
} }
setparameter(c, 0, p, &config[p].val);
} }
curconfig = newconfig;
} }
void void
@ -716,6 +707,8 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
GdkRGBA bgcolor = { 0 }; GdkRGBA bgcolor = { 0 };
WebKitSettings *s = webkit_web_view_get_settings(c->view); WebKitSettings *s = webkit_web_view_get_settings(c->view);
modparams[p] = curconfig[p].prio;
switch (p) { switch (p) {
case AcceleratedCanvas: case AcceleratedCanvas:
webkit_settings_set_enable_accelerated_2d_canvas(s, a->i); webkit_settings_set_enable_accelerated_2d_canvas(s, a->i);