From 8b0a7a697f5bc5fb2733592270c1a1f1174d1f5a Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Tue, 26 May 2015 16:45:52 +0200 Subject: [PATCH] Filter excessive newlines. The way our HTML parser triggers newlines is a guess at best. On the other hand our screen estate is severely limited. Instead of trying to (further) improve the way we translate tags to newlines it seems more reasonable to simply never render more than two successive empty lines. --- apps/webbrowser/www.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/webbrowser/www.c b/apps/webbrowser/www.c index 3acea84b5..0d2dd6ab0 100644 --- a/apps/webbrowser/www.c +++ b/apps/webbrowser/www.c @@ -182,6 +182,7 @@ static char *webpageptr; static unsigned char x, y; static unsigned char loading; static unsigned short firsty, pagey; +static unsigned char newlines; static unsigned char count; static char receivingmsgs[4][23] = { @@ -278,6 +279,7 @@ start_loading(void) loading = 1; x = y = 0; pagey = 0; + newlines = 0; webpageptr = webpage; clear_page(); @@ -732,6 +734,8 @@ add_pagewidget(char *text, unsigned char size, char *attrib, unsigned char type, char *wptr; static unsigned char maxwidth; + newlines = 0; + if(!loading) { return; } @@ -838,6 +842,10 @@ htmlparser_newline(void) { char *wptr; + if(++newlines > 2) { + return; + } + if(pagey < firsty) { ++pagey; x = 0; @@ -864,6 +872,8 @@ htmlparser_newline(void) void htmlparser_word(char *word, unsigned char wordlen) { + newlines = 0; + if(loading) { if(wordlen + 1 > WWW_CONF_WEBPAGE_WIDTH - x) { htmlparser_newline();