summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dillorc5
-rw-r--r--src/dicache.c2
-rw-r--r--src/html.cc15
-rw-r--r--src/plain.cc24
-rw-r--r--src/prefs.c3
-rw-r--r--src/prefs.h1
-rw-r--r--src/styleengine.cc5
-rw-r--r--src/styleengine.hh1
-rw-r--r--src/table.cc19
-rw-r--r--src/web.cc29
-rw-r--r--src/web.hh1
11 files changed, 35 insertions, 70 deletions
diff --git a/dillorc b/dillorc
index 0316e71c..af2893be 100644
--- a/dillorc
+++ b/dillorc
@@ -144,11 +144,6 @@
# Here we can use the HTML color names or C syntax.
-# Set the background color
-# bg_color=gray
-# bg_color=0xd6d6c0
-#bg_color=0xdcd1ba
-
# Set the text color
#text_color=black
diff --git a/src/dicache.c b/src/dicache.c
index 86578ba1..109f1b36 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -399,7 +399,7 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr,
dReturn_val_if_fail(MimeType && Ptr, NULL);
if (!web->Image)
- web->Image = a_Image_new(0, 0, NULL, prefs.bg_color);
+ web->Image = a_Image_new(0, 0, NULL, web->bgColor);
/* Add an extra reference to the Image (for dicache usage) */
a_Image_ref(web->Image);
diff --git a/src/html.cc b/src/html.cc
index c8d9e63f..4c2bdbf6 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -425,6 +425,8 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
DocType = DT_NONE; /* assume Tag Soup 0.0! :-) */
DocTypeVersion = 0.0f;
+ styleEngine = new StyleEngine (HT2LT (this));
+
cssUrls = new misc::SimpleVector <DilloUrl*> (1);
stack = new misc::SimpleVector <DilloHtmlState> (16);
@@ -439,11 +441,10 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
stack->getRef(0)->textblock = NULL;
stack->getRef(0)->table = NULL;
stack->getRef(0)->ref_list_item = NULL;
- stack->getRef(0)->current_bg_color = prefs.bg_color;
+ stack->getRef(0)->current_bg_color =
+ styleEngine->style()->backgroundColor->getColor();
stack->getRef(0)->hand_over_break = false;
- styleEngine = new StyleEngine (HT2LT (this));
-
InFlags = IN_NONE;
Stash = dStr_new("");
@@ -1694,11 +1695,9 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
textblock = DW2TB(html->dw);
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) {
- color = a_Html_color_parse(html, attrbuf, prefs.bg_color);
- if (color == 0xffffff && !prefs.allow_white_bg)
- color = prefs.bg_color;
- S_TOP(html)->current_bg_color = color;
- props.set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, color);
+ color = a_Html_color_parse(html, attrbuf, -1);
+ if (color != -1)
+ props.set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, color);
}
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "text"))) {
diff --git a/src/plain.cc b/src/plain.cc
index 5366f87e..5111912a 100644
--- a/src/plain.cc
+++ b/src/plain.cc
@@ -22,6 +22,7 @@
#include "bw.h"
#include "web.hh"
#include "misc.h"
+#include "styleengine.hh"
#include "uicmd.hh"
@@ -85,9 +86,6 @@ void a_Plain_free(void *data);
*/
DilloPlain::DilloPlain(BrowserWindow *p_bw, const DilloUrl *p_url)
{
- style::StyleAttrs styleAttrs;
- style::FontAttrs fontAttrs;
-
/* Init event receiver */
plainReceiver.plain = this;
@@ -98,20 +96,12 @@ DilloPlain::DilloPlain(BrowserWindow *p_bw, const DilloUrl *p_url)
Start_Ofs = 0;
state = ST_SeekingEol;
- /* Create the font and attribute for the page. */
- fontAttrs.name = prefs.font_monospace;
- fontAttrs.size = (int) rint(14.0 * prefs.font_factor);
- fontAttrs.weight = 400;
- fontAttrs.style = style::FONT_STYLE_NORMAL;
-
- Layout *layout = (Layout*)bw->render_layout;
- styleAttrs.initValues ();
- styleAttrs.margin.setVal (5);
- styleAttrs.font = style::Font::create (layout, &fontAttrs);
- styleAttrs.color = style::Color::create (layout, prefs.text_color);
- styleAttrs.backgroundColor =
- style::Color::create (layout, prefs.bg_color);
- widgetStyle = style::Style::create (layout, &styleAttrs);
+ StyleEngine styleEngine ((Layout*)bw->render_layout);
+
+ styleEngine.startElement ("body");
+ styleEngine.startElement ("pre");
+ widgetStyle = styleEngine.wordStyle ();
+ widgetStyle->ref ();
/* The context menu */
DW2TB(dw)->connectEvent (&plainReceiver);
diff --git a/src/prefs.c b/src/prefs.c
index 815262c0..e0b746ae 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -43,7 +43,6 @@
#define D_SEARCH_URL "http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s"
#define D_SAVE_DIR "/tmp/"
-#define DW_COLOR_DEFAULT_BGND 0xdcd1ba
#define DW_COLOR_DEFAULT_TEXT 0x000000
#define DW_COLOR_DEFAULT_LINK 0x0000ff
#define DW_COLOR_DEFAULT_VLINK 0x800080
@@ -154,7 +153,6 @@ static int Prefs_parse_dillorc(void)
/* Symbol array, sorted alphabetically */
const SymNode_t symbols[] = {
{ "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL },
- { "bg_color", &prefs.bg_color, PREFS_COLOR },
{ "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32 },
{ "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL },
{ "enterpress_forces_submit", &prefs.enterpress_forces_submit, PREFS_BOOL },
@@ -260,7 +258,6 @@ void a_Prefs_init(void)
char *old_locale;
prefs.allow_white_bg = TRUE;
- prefs.bg_color = DW_COLOR_DEFAULT_BGND;
prefs.buffered_drawing=1;
prefs.contrast_visited_color = TRUE;
prefs.enterpress_forces_submit = FALSE;
diff --git a/src/prefs.h b/src/prefs.h
index 1c15c147..bd11517a 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -31,7 +31,6 @@ struct _DilloPrefs {
DilloUrl *home;
int32_t link_color;
int32_t visited_color;
- int32_t bg_color;
int32_t text_color;
bool_t allow_white_bg;
bool_t force_my_colors;
diff --git a/src/styleengine.cc b/src/styleengine.cc
index cde1f926..35e37543 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -13,6 +13,7 @@
#include <math.h>
#include "../dlib/dlib.h"
#include "prefs.h"
+#include "html_common.hh"
#include "styleengine.hh"
using namespace dw::core::style;
@@ -85,6 +86,10 @@ void StyleEngine::startElement (int element) {
n->inheritBackgroundColor = false;
}
+void StyleEngine::startElement (const char *tagname) {
+ startElement (a_Html_tag_index (tagname));
+}
+
void StyleEngine::setId (const char *id) {
Node *n = stack->getRef (stack->size () - 1);
assert (n->id == NULL);
diff --git a/src/styleengine.hh b/src/styleengine.hh
index a324b419..732808fa 100644
--- a/src/styleengine.hh
+++ b/src/styleengine.hh
@@ -47,6 +47,7 @@ class StyleEngine : public Doctree {
void parse (const char *buf, int buflen, CssOrigin origin);
void startElement (int tag);
+ void startElement (const char *tagname);
void setId (const char *id);
const char * getId () { return top ()->id; };
void setClass (const char *klass);
diff --git a/src/table.cc b/src/table.cc
index 53325410..5964d88e 100644
--- a/src/table.cc
+++ b/src/table.cc
@@ -90,12 +90,8 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) {
bgcolor = a_Html_color_parse(html, attrbuf, -1);
- if (bgcolor != -1) {
- if (bgcolor == 0xffffff && !prefs.allow_white_bg)
- bgcolor = prefs.bg_color;
- S_TOP(html)->current_bg_color = bgcolor;
+ if (bgcolor != -1)
props.set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, bgcolor);
- }
}
html->styleEngine->setNonCssHints (&props);
@@ -165,12 +161,8 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) {
bgcolor = a_Html_color_parse(html, attrbuf, -1);
- if (bgcolor != -1) {
- if (bgcolor == 0xffffff && !prefs.allow_white_bg)
- bgcolor = prefs.bg_color;
+ if (bgcolor != -1)
props.set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, bgcolor);
- S_TOP(html)->current_bg_color = bgcolor;
- }
}
if (a_Html_get_attr (html, tag, tagsize, "align")) {
@@ -294,13 +286,8 @@ static void Html_tag_open_table_cell(DilloHtml *html,
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) {
bgcolor = a_Html_color_parse(html, attrbuf, -1);
- if (bgcolor != -1) {
- if (bgcolor == 0xffffff && !prefs.allow_white_bg)
- bgcolor = prefs.bg_color;
-
+ if (bgcolor != -1)
props->set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, bgcolor);
- S_TOP(html)->current_bg_color = bgcolor;
- }
}
html->styleEngine->setNonCssHints (props);
diff --git a/src/web.cc b/src/web.cc
index ff2b90ad..660cd8e3 100644
--- a/src/web.cc
+++ b/src/web.cc
@@ -23,6 +23,7 @@
#include "dw/core.hh"
#include "prefs.h"
+#include "styleengine.hh"
#include "web.hh"
// Platform independent part
@@ -54,9 +55,6 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
CA_Callback_t *Call, void **Data)
{
Widget *dw = NULL;
- style::StyleAttrs styleAttrs;
- style::Style *widgetStyle;
- style::FontAttrs fontAttrs;
_MSG("a_Web_dispatch_by_type\n");
@@ -67,25 +65,17 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
if (Web->flags & WEB_RootUrl) {
/* We have RootUrl! */
+
+ /* Set a style for the widget */
+ StyleEngine styleEngine (layout);
+ styleEngine.startElement ("body");
+ Web->bgColor = styleEngine.backgroundStyle ()->backgroundColor->getColor ();
+
dw = (Widget*) a_Mime_set_viewer(Type, Web, Call, Data);
if (dw == NULL)
return -1;
- /* Set a style for the widget */
- fontAttrs.name = prefs.font_sans_serif;
- fontAttrs.size = (int) rint(14.0 * prefs.font_factor);
- fontAttrs.weight = 400;
- fontAttrs.style = style::FONT_STYLE_NORMAL;
-
- styleAttrs.initValues ();
- styleAttrs.margin.setVal (5);
- styleAttrs.font = style::Font::create (layout, &fontAttrs);
- styleAttrs.color = style::Color::create (layout, 0xff0000);
- styleAttrs.backgroundColor =
- style::Color::create (layout, prefs.bg_color);
- widgetStyle = style::Style::create (layout, &styleAttrs);
- dw->setStyle (widgetStyle);
- widgetStyle->unref ();
+ dw->setStyle (styleEngine.style ());
/* This method frees the old dw if any */
layout->setWidget(dw);
@@ -130,7 +120,8 @@ DilloWeb* a_Web_new(const DilloUrl *url)
web->filename = NULL;
web->stream = NULL;
web->SavedBytes = 0;
-
+ web->bgColor = 0x000000; /* Dummy value will be overwritten
+ * in a_Web_dispatch_by_type. */
dList_append(ValidWebs, (void *)web);
return web;
}
diff --git a/src/web.hh b/src/web.hh
index a5e05a2f..2671c6ef 100644
--- a/src/web.hh
+++ b/src/web.hh
@@ -27,6 +27,7 @@ struct _DilloWeb {
DilloImage *Image; /* For image urls [reference] */
+ int32_t bgColor; /* for image backgrounds */
char *filename; /* Variables for Local saving */
FILE *stream;
int SavedBytes;