From 8e650e3e39771431267aa6275d596516d1e34abb Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Fri, 30 Jul 2004 23:40:01 +0000 Subject: [project @ 2004-07-30 23:40:00 by jmb] Rework stylesheet fetching code to remove dependence on magic numbers (now uses values defined in html.h) Make ad blocking optional. svn path=/import/netsurf/; revision=1168 --- !NetSurf/Resources/CSS,f79 | 4 +-- desktop/browser.c | 3 ++- desktop/options.c | 3 +++ desktop/options.h | 1 + render/html.c | 67 +++++++++++++++++++++++++++++++--------------- render/html.h | 9 +++++-- riscos/save_complete.c | 6 ++--- 7 files changed, 62 insertions(+), 31 deletions(-) diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79 index 6f89ea5c1..2b0575d3d 100644 --- a/!NetSurf/Resources/CSS,f79 +++ b/!NetSurf/Resources/CSS,f79 @@ -1,9 +1,7 @@ /* * This file is part of NetSurf, http://netsurf.sourceforge.net/ */ - -@import url('AdBlock'); - + /* Elements ordered as in the HTML 4.01 specification. */ html { display: block; } diff --git a/desktop/browser.c b/desktop/browser.c index fabd7ab4e..c4dcc5c54 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -432,7 +432,8 @@ void browser_window_reload(struct browser_window *bw, bool all) c->data.html.object[i].content->fresh = false; } /* invalidate stylesheets */ - for (i=2; i!=c->data.html.stylesheet_count; i++) { + for (i=STYLESHEET_START; + i!=c->data.html.stylesheet_count; i++) { if (c->data.html.stylesheet_content[i] != 0) c->data.html.stylesheet_content[i]->fresh = false; } diff --git a/desktop/options.c b/desktop/options.c index c999e0ea6..ab3653e1e 100644 --- a/desktop/options.c +++ b/desktop/options.c @@ -51,6 +51,8 @@ char *option_accept_language = 0; bool option_ssl_verify_certificates = true; /** Preferred maximum size of memory cache / bytes. */ int option_memory_cache_size = 2 * 1024 * 1024; +/** Whether to block advertisements */ +bool option_block_ads = false; EXTRA_OPTION_DEFINE @@ -71,6 +73,7 @@ struct { { "accept_language", OPTION_STRING, &option_accept_language }, { "ssl_verify_certificates", OPTION_BOOL, &option_ssl_verify_certificates }, { "memory_cache_size", OPTION_INTEGER, &option_memory_cache_size }, + { "block_advertisements", OPTION_BOOL, &option_block_ads }, EXTRA_OPTION_TABLE }; diff --git a/desktop/options.h b/desktop/options.h index 65fa59fc2..ae35cda94 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -38,6 +38,7 @@ extern int option_font_min_size; extern char *option_accept_language; extern bool option_ssl_verify_certificates; extern int option_memory_cache_size; +extern bool option_block_ads; void options_read(const char *path); void options_write(const char *path); diff --git a/render/html.c b/render/html.c index 5fce63c26..7bda3b02a 100644 --- a/render/html.c +++ b/render/html.c @@ -23,6 +23,7 @@ #ifdef riscos #include "netsurf/desktop/gui.h" #endif +#include "netsurf/desktop/options.h" #include "netsurf/render/html.h" #include "netsurf/render/layout.h" #include "netsurf/utils/log.h" @@ -326,30 +327,52 @@ void html_find_stylesheets(struct content *c, xmlNode *head) { xmlNode *node, *node2; char *rel, *type, *media, *href, *data, *url; - unsigned int i = 2; + unsigned int i = STYLESHEET_START; unsigned int last_active = 0; union content_msg_data msg_data; - /* stylesheet 0 is the base style sheet, stylesheet 1 is any