changeset 527:70e94ff49dc4

remove style from DilloHtmlState
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Fri, 31 Oct 2008 16:22:01 +0100
parents bda9f951f971
children ec2fae048155
files src/form.cc src/html.cc src/html_common.hh src/table.cc
diffstat 4 files changed, 21 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/form.cc	Fri Oct 31 15:20:06 2008 +0100
+++ b/src/form.cc	Fri Oct 31 16:22:01 2008 +0100
@@ -277,7 +277,7 @@
    char *charset, *first;
    const char *attrbuf;
 
-   DW2TB(html->dw)->addParbreak (9, S_TOP(html)->style);
+   DW2TB(html->dw)->addParbreak (9, html->styleEngine->style ());
 
    if (html->InFlags & IN_FORM) {
       BUG_MSG("nested forms\n");
@@ -540,7 +540,7 @@
          bg = Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color);
       HTML_SET_TOP_ATTR(html, backgroundColor, bg);
 
-      DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style);
+      DW2TB(html->dw)->addWidget (embed, html->styleEngine->style ());
    }
    dFree(type);
    dFree(name);
@@ -573,10 +573,10 @@
                  html->charset);
    html->InFlags |= IN_FORM;
 
-   DW2TB(html->dw)->addParbreak (9, S_TOP(html)->style);
+   DW2TB(html->dw)->addParbreak (9, html->styleEngine->style ());
 
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "prompt")))
-      DW2TB(html->dw)->addText(attrbuf, S_TOP(html)->style);
+      DW2TB(html->dw)->addText(attrbuf, html->styleEngine->style ());
 
    ResourceFactory *factory = HT2LT(html)->getResourceFactory();
    EntryResource *entryResource = factory->createEntryResource (20, false);
@@ -589,7 +589,7 @@
    else
       bg = Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color);
    HTML_SET_TOP_ATTR(html, backgroundColor, bg);
-   DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style);
+   DW2TB(html->dw)->addWidget (embed, html->styleEngine->style ());
 
    a_Url_free(action);
    html->InFlags &= ~IN_FORM;
@@ -658,7 +658,7 @@
       bg = Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color);
    HTML_SET_TOP_ATTR(html, backgroundColor, bg);
 
-   DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style);
+   DW2TB(html->dw)->addWidget (embed, html->styleEngine->style ());
    dFree(name);
 }
 
@@ -740,7 +740,7 @@
    }
    HTML_SET_TOP_ATTR(html, backgroundColor,
                      Color::createShaded (HT2LT(html), bg));
-   DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style);
+   DW2TB(html->dw)->addWidget (embed, html->styleEngine->style ());
 
 // size = 0;
 // if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "size")))
@@ -861,7 +861,7 @@
       Embed *embed;
       char *name, *value;
 
-      style_attrs = *S_TOP(html)->style;
+      style_attrs = *html->styleEngine->style ();
       style_attrs.margin.setVal(0);
       style_attrs.borderWidth.setVal(0);
       style_attrs.padding.setVal(0);
@@ -1904,7 +1904,7 @@
 
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "src")) &&
        (url = a_Html_url_new(html, attrbuf, NULL, 0))) {
-      style_attrs = *S_TOP(html)->style;
+      style_attrs = *html->styleEngine->style ();
       style_attrs.cursor = CURSOR_POINTER;
       style_attrs.backgroundColor =
         style::Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color);
--- a/src/html.cc	Fri Oct 31 15:20:06 2008 +0100
+++ b/src/html.cc	Fri Oct 31 16:22:01 2008 +0100
@@ -469,7 +469,6 @@
 
    stack = new misc::SimpleVector <DilloHtmlState> (16);
    stack->increase();
-   stack->getRef(0)->style = NULL;
    stack->getRef(0)->table_cell_style = NULL;
    stack->getRef(0)->parse_mode = DILLO_HTML_PARSE_MODE_INIT;
    stack->getRef(0)->table_mode = DILLO_HTML_TABLE_MODE_NONE;
@@ -528,25 +527,11 @@
  */
 void DilloHtml::initDw()
 {
-   StyleAttrs style_attrs;
-   FontAttrs font_attrs;
-
    dReturn_if_fail (dw == NULL);
 
    /* Create the main widget */
    dw = stack->getRef(0)->textblock = new Textblock (prefs.limit_text_width);
 
-   /* Create a dummy font, attribute, and tag for the bottom of the stack. */
-   font_attrs.name = prefs.vw_fontname;
-   font_attrs.size = Html_level_to_fontsize(FontSizesBase);
-   font_attrs.weight = 400;
-   font_attrs.style = FONT_STYLE_NORMAL;
-
-   style_attrs.initValues ();
-   style_attrs.font = Font::create (HT2LT(this), &font_attrs);
-   style_attrs.color = Color::createSimple (HT2LT(this), prefs.text_color);
-   stack->getRef(0)->style = Style::create (HT2LT(this), &style_attrs);
-
    stack->getRef(0)->table_cell_style = NULL;
 
    /* Handle it when the user clicks on a link */
--- a/src/html_common.hh	Fri Oct 31 15:20:06 2008 +0100
+++ b/src/html_common.hh	Fri Oct 31 16:22:01 2008 +0100
@@ -114,7 +114,8 @@
 };
 
 struct _DilloHtmlState {
-   dw::core::style::Style *style, *table_cell_style;
+//   dw::core::style::Style *style, *table_cell_style;
+   dw::core::style::Style *table_cell_style;
    DilloHtmlParseMode parse_mode;
    DilloHtmlTableMode table_mode;
    bool cell_text_align_set;
--- a/src/table.cc	Fri Oct 31 15:20:06 2008 +0100
+++ b/src/table.cc	Fri Oct 31 16:22:01 2008 +0100
@@ -49,7 +49,7 @@
    int32_t border = 0, cellspacing = 1, cellpadding = 2, bgcolor;
 #endif
 
-   DW2TB(html->dw)->addParbreak (0, S_TOP(html)->style);
+   DW2TB(html->dw)->addParbreak (0, html->styleEngine->style ());
 
 #ifdef USE_TABLES
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "border")))
@@ -60,7 +60,7 @@
       cellpadding = strtol (attrbuf, NULL, 10);
 
    /* The style for the table */
-   style_attrs = *S_TOP(html)->style;
+   style_attrs = *html->styleEngine->style ();
 
    /* When dillo was started with the --debug-rendering option, there
     * is always a border around the table. */
@@ -101,7 +101,7 @@
 
    /* The style for the cells */
    cell_style = Style::create (HT2LT(html), &style_attrs);
-   style_attrs = *S_TOP(html)->style;
+   style_attrs = *html->styleEngine->style ();
    /* When dillo was started with the --debug-rendering option, there
     * is always a border around the cells. */
    if (dillo_dbg_rendering)
@@ -157,7 +157,7 @@
             if (bgcolor == 0xffffff && !prefs.allow_white_bg)
                bgcolor = prefs.bg_color;
 
-            style_attrs = *S_TOP(html)->style;
+            style_attrs = *html->styleEngine->style ();
             style_attrs.backgroundColor =
                Color::createShaded (HT2LT(html), bgcolor);
             style = Style::create (HT2LT(html), &style_attrs);
@@ -194,7 +194,7 @@
 
    S_TOP(html)->table_mode = DILLO_HTML_TABLE_MODE_TR;
 #else
-   DW2TB(html->dw)->addParbreak (0, S_TOP(html)->style);
+   DW2TB(html->dw)->addParbreak (0, html->styleEngine->style ());
 #endif
 }
 
@@ -259,7 +259,7 @@
          rowspan = MAX(1, strtol (attrbuf, NULL, 10));
 
       /* text style */
-      old_style = S_TOP(html)->style;
+      old_style = html->styleEngine->style ();
       style_attrs = *old_style;
       if (!S_TOP(html)->cell_text_align_set)
          style_attrs.textAlign = text_align;
@@ -268,9 +268,9 @@
       else
          style_attrs.whiteSpace = WHITE_SPACE_NORMAL;
 
-      S_TOP(html)->style =
-         Style::create (HT2LT(html), &style_attrs);
-      old_style->unref ();
+//      html->styleEngine->style () =
+//         Style::create (HT2LT(html), &style_attrs);
+//      old_style->unref ();
       a_Html_tag_set_align_attr (html, tag, tagsize);
 
       /* cell style */
@@ -299,7 +299,7 @@
          }
       }
 
-      if (S_TOP(html)->style->textAlign
+      if (html->styleEngine->style ()->textAlign
           == TEXT_ALIGN_STRING)
          col_tb = new dw::TableCell (((dw::Table*)S_TOP(html)->table)->getCellRef (),
                                      prefs.limit_text_width);