Rectify how parameters are handled in setparameter()

Access parameters through given Arg parameter instead of accessing
global parameters.
This commit is contained in:
Quentin Rameau 2016-01-09 12:57:39 +01:00
parent 6e019362c5
commit c8fdd4d583

45
surf.c
View file

@ -571,6 +571,7 @@ seturiparameters(Client *c, const char *uri)
void void
setparameter(Client *c, int refresh, ParamName p, const Arg *a) setparameter(Client *c, int refresh, ParamName p, const Arg *a)
{ {
GdkRGBA bgcolor = { 0 };
WebKitSettings *s = webkit_web_view_get_settings(c->view); WebKitSettings *s = webkit_web_view_get_settings(c->view);
switch (p) { switch (p) {
@ -587,28 +588,29 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
break; break;
case DiskCache: case DiskCache:
webkit_web_context_set_cache_model( webkit_web_context_set_cache_model(
webkit_web_view_get_context(c->view), webkit_web_view_get_context(c->view), a->b ?
curconfig[DiskCache].val.b ?
WEBKIT_CACHE_MODEL_WEB_BROWSER : WEBKIT_CACHE_MODEL_WEB_BROWSER :
WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
break; return; /* do not update */
case DNSPrefetch: case DNSPrefetch:
refresh = 0; webkit_settings_set_enable_dns_prefetching(s, a->b);
break; return; /* do not update */
case FontSize: case FontSize:
webkit_settings_set_default_font_size( webkit_settings_set_default_font_size(s, a->i);
webkit_web_view_get_settings(c->view), return; /* do not update */
curconfig[FontSize].val.i);
break;
case FrameFlattening: case FrameFlattening:
webkit_settings_set_enable_frame_flattening(s, a->b); webkit_settings_set_enable_frame_flattening(s, a->b);
break; break;
case Geolocation: case Geolocation:
refresh = 0;
break; break;
case HideBackground: case HideBackground:
return; /* do nothing */ if (a->b)
webkit_web_view_set_background_color(c->view, &bgcolor);
return; /* do not update */
case Inspector: case Inspector:
return; /* do nothing */ webkit_settings_set_enable_developer_extras(s, a->b);
return; /* do not update */
case JavaScript: case JavaScript:
webkit_settings_set_enable_javascript(s, a->b); webkit_settings_set_enable_javascript(s, a->b);
break; break;
@ -631,25 +633,23 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
evalscript(c, "document.documentElement.style.overflow = '%s'", evalscript(c, "document.documentElement.style.overflow = '%s'",
enablescrollbars ? "auto" : "hidden"); enablescrollbars ? "auto" : "hidden");
*/ */
refresh = 0; return; /* do not update */
break;
case ShowIndicators: case ShowIndicators:
return; /* do nothing */ break;
case SpellChecking: case SpellChecking:
webkit_web_context_set_spell_checking_enabled( webkit_web_context_set_spell_checking_enabled(
webkit_web_view_get_context(c->view), webkit_web_view_get_context(c->view), a->b);
curconfig[SpellChecking].val.b); return; /* do not update */
return; /* do nothing */
case SpellLanguages: case SpellLanguages:
return; /* do nothing */ return; /* do nothing */
case StrictSSL: case StrictSSL:
webkit_web_context_set_tls_errors_policy( webkit_web_context_set_tls_errors_policy(
webkit_web_view_get_context(c->view), webkit_web_view_get_context(c->view), a->b ?
curconfig[StrictSSL].val.b ? WEBKIT_TLS_ERRORS_POLICY_FAIL : WEBKIT_TLS_ERRORS_POLICY_FAIL :
WEBKIT_TLS_ERRORS_POLICY_IGNORE); WEBKIT_TLS_ERRORS_POLICY_IGNORE);
return; /* do nothing */ return; /* do not update */
case Style: case Style:
if (curconfig[Style].val.b) if (a->b)
setstyle(c, getstyle(geturi(c))); setstyle(c, getstyle(geturi(c)));
else else
webkit_user_content_manager_remove_all_style_sheets( webkit_user_content_manager_remove_all_style_sheets(
@ -657,7 +657,8 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
refresh = 0; refresh = 0;
break; break;
case ZoomLevel: case ZoomLevel:
return; /* do nothing */ webkit_web_view_set_zoom_level(c->view, a->f);
return; /* do not update */
default: default:
return; /* do nothing */ return; /* do nothing */
} }