mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-21 22:11:22 +03:00
css: Add option to ignore author level CSS
This adds a new config option, `author_level_css`. When it is disabled, NetSurf will ignore all CSS from the web page. In this case only the default CSS rules from the browser and user CSS rules will be applied. It is enabled by default. Tested by running: ./nsgtk3 --author_level_css=0
This commit is contained in:
parent
41de6cb6f8
commit
4cb38c4704
@ -1587,6 +1587,10 @@ static void css_hint_list(
|
||||
dom_exception err;
|
||||
dom_string *attr;
|
||||
|
||||
if (nsoption_bool(author_level_css) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
err = dom_element_get_attribute(node, corestring_dom_type, &attr);
|
||||
if (err == DOM_NO_ERR && attr != NULL) {
|
||||
const char *attr_str = dom_string_data(attr);
|
||||
|
@ -249,16 +249,19 @@ box_get_style(html_content *c,
|
||||
const css_computed_style *root_style,
|
||||
dom_node *n)
|
||||
{
|
||||
dom_string *s;
|
||||
dom_exception err;
|
||||
dom_string *s = NULL;
|
||||
css_stylesheet *inline_style = NULL;
|
||||
css_select_results *styles;
|
||||
nscss_select_ctx ctx;
|
||||
|
||||
/* Firstly, construct inline stylesheet, if any */
|
||||
err = dom_element_get_attribute(n, corestring_dom_style, &s);
|
||||
if (err != DOM_NO_ERR)
|
||||
return NULL;
|
||||
if (nsoption_bool(author_level_css)) {
|
||||
dom_exception err;
|
||||
err = dom_element_get_attribute(n, corestring_dom_style, &s);
|
||||
if (err != DOM_NO_ERR) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s != NULL) {
|
||||
inline_style = nscss_create_inline_style(
|
||||
|
@ -683,6 +683,11 @@ html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
|
||||
origin = CSS_ORIGIN_USER;
|
||||
}
|
||||
|
||||
if (origin == CSS_ORIGIN_AUTHOR &&
|
||||
nsoption_bool(author_level_css) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hsheet->sheet != NULL) {
|
||||
sheet = nscss_get_stylesheet(hsheet->sheet);
|
||||
}
|
||||
|
@ -123,6 +123,9 @@ NSOPTION_BOOL(animate_images, true)
|
||||
/** Whether to execute javascript */
|
||||
NSOPTION_BOOL(enable_javascript, false)
|
||||
|
||||
/** Whether to allow Author level CSS. */
|
||||
NSOPTION_BOOL(author_level_css, true)
|
||||
|
||||
/** Maximum time (in seconds) to wait for a script to run */
|
||||
NSOPTION_INTEGER(script_timeout, 10)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user