changeset 351:6fdc59173d00

- reverted all of the style->backgroundColor to current_bg_color - Fixed table_cell_style's backgroundColor when TR specifies one.
author jcid
date Fri, 26 Sep 2008 16:37:38 +0200
parents 118fe0444e08
children 44a801a15c88
files src/form.cc src/html.cc src/html_common.hh src/table.cc
diffstat 4 files changed, 62 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/form.cc	Fri Sep 26 00:53:13 2008 +0200
+++ b/src/form.cc	Fri Sep 26 16:37:38 2008 +0200
@@ -550,14 +550,15 @@
 //          gtk_entry_set_max_length(GTK_ENTRY(widget),
 //                                   strtol(attrbuf, NULL, 10));
       }
+      Color *bg;
+      if (prefs.standard_widget_colors)
+         bg = NULL;
+      else
+         bg = Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color);
+      HTML_SET_TOP_ATTR(html, backgroundColor, bg);
 
-      if (prefs.standard_widget_colors) {
-         HTML_SET_TOP_ATTR(html, color, NULL);
-         HTML_SET_TOP_ATTR(html, backgroundColor, NULL);
-      }
       DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style);
    }
-  
    dFree(type);
    dFree(name);
    if (init_str != value)
@@ -599,12 +600,14 @@
    embed = new dw::core::ui::Embed (entryResource);
    Html_add_input(html, DILLO_HTML_INPUT_INDEX, embed, NULL, NULL, FALSE);
 
-   if (prefs.standard_widget_colors) {
-      HTML_SET_TOP_ATTR(html, color, NULL);
-      HTML_SET_TOP_ATTR(html, backgroundColor, NULL);
-   }
+   Color *bg;
+   if (prefs.standard_widget_colors)
+      bg = NULL;
+   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);
-  
+
    a_Url_free(action);
    html->InFlags &= ~IN_FORM;
 }
@@ -664,6 +667,14 @@
    if (a_Html_get_attr(html, tag, tagsize, "readonly"))
       textres->setEditable(false);
    Html_add_input(html, DILLO_HTML_INPUT_TEXTAREA, embed, name, NULL, false);
+
+   Color *bg;
+   if (prefs.standard_widget_colors)
+      bg = NULL;
+   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);
    dFree(name);
 }
@@ -738,12 +749,17 @@
       res = factory->createOptionMenuResource ();
    }
    dw::core::ui::Embed *embed = new dw::core::ui::Embed(res);
+
+   int bg;
    if (prefs.standard_widget_colors) {
-      /* Colors cannot be NULL because SELECT can contain other elements */
+      /* Valid colors required; SELECT can contain other elements (BUG) */
       HTML_SET_TOP_ATTR(html, color, Color::createSimple (HT2LT(html), 0));
-      HTML_SET_TOP_ATTR(html, backgroundColor,
-                        Color::createShaded (HT2LT(html), 0xffffff));
+      bg = 0xffffff;
+   } else {
+      bg = S_TOP(html)->current_bg_color;
    }
+   HTML_SET_TOP_ATTR(html, backgroundColor,
+                     Color::createShaded (HT2LT(html), bg));
    DW2TB(html->dw)->addWidget (embed, S_TOP(html)->style);
 
 // size = 0;
@@ -873,6 +889,8 @@
       style_attrs.margin.setVal(0);
       style_attrs.borderWidth.setVal(0);
       style_attrs.padding.setVal(0);
+      style_attrs.backgroundColor =
+               Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color);
       style = Style::create (HT2LT(html), &style_attrs);
 
       page = new Textblock (prefs.limit_text_width);
@@ -1925,6 +1943,8 @@
        (url = a_Html_url_new(html, attrbuf, NULL, 0))) {
       style_attrs = *S_TOP(html)->style;
       style_attrs.cursor = CURSOR_POINTER;
+      style_attrs.backgroundColor =
+        style::Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color);
 
       /* create new image and add it to the button */
       if ((Image = a_Html_add_new_image(html, tag, tagsize, url, &style_attrs,
--- a/src/html.cc	Fri Sep 26 00:53:13 2008 +0200
+++ b/src/html.cc	Fri Sep 26 16:37:38 2008 +0200
@@ -479,6 +479,7 @@
    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)->hand_over_break = false;
 
    InFlags = IN_NONE;
@@ -541,8 +542,6 @@
    style_attrs.initValues ();
    style_attrs.font = Font::create (HT2LT(this), &font_attrs);
    style_attrs.color = Color::createSimple (HT2LT(this), prefs.text_color);
-   style_attrs.backgroundColor =
-                        Color::createShaded (HT2LT(this), prefs.bg_color);
    stack->getRef(0)->style = Style::create (HT2LT(this), &style_attrs);
 
    stack->getRef(0)->table_cell_style = NULL;
@@ -1734,8 +1733,7 @@
          style = Style::create (HT2LT(html), &style_attrs);
          html->dw->setStyle (style);
          style->unref ();
-         HTML_SET_TOP_ATTR (html, backgroundColor,
-                            Color::createShaded (HT2LT(html), color));
+         S_TOP(html)->current_bg_color = color;
       }
 
       if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "text"))) {
@@ -1757,7 +1755,7 @@
             a_Color_vc(html->visited_color,
                        S_TOP(html)->style->color->getColor(),
                        html->link_color,
-                       S_TOP(html)->style->backgroundColor->getColor());
+                       S_TOP(html)->current_bg_color);
       }
    }
 
@@ -2120,7 +2118,7 @@
    style_attrs->x_img = html->images->size();
 
    /* Add a new image widget to this page */
-   Image = a_Image_new(0,0,alt_ptr,style_attrs->backgroundColor->getColor());
+   Image = a_Image_new(0, 0, alt_ptr, S_TOP(html)->current_bg_color);
    if (add) {
       Html_add_widget(html, (Widget*)Image->dw, width_ptr, height_ptr,
                       style_attrs);
@@ -2499,7 +2497,7 @@
             a_Color_vc(html->visited_color,
                        S_TOP(html)->style->color->getColor(),
                        html->link_color,
-                       S_TOP(html)->style->backgroundColor->getColor()),
+                       S_TOP(html)->current_bg_color),
 */
             );
       } else {
@@ -2811,7 +2809,7 @@
       style_attrs.setBorderStyle (BORDER_INSET);
       style_attrs.setBorderColor
          (Color::createShaded (HT2LT(html),
-                               style_attrs.backgroundColor->getColor()));
+                               S_TOP(html)->current_bg_color));
       if (size < 2)
          size = 2;
    }
--- a/src/html_common.hh	Fri Sep 26 00:53:13 2008 +0200
+++ b/src/html_common.hh	Fri Sep 26 16:37:38 2008 +0200
@@ -124,6 +124,10 @@
    /* This is used to align list items (especially in enumerated lists) */
    dw::core::Widget *ref_list_item;
 
+   /* This makes image processing faster than a function
+      a_Dw_widget_get_background_color. */
+   int32_t current_bg_color;
+
    /* This is used for list items etc; if it is set to TRUE, breaks
       have to be "handed over" (see Html_add_indented and
       Html_eventually_pop_dw). */
--- a/src/table.cc	Fri Sep 26 00:53:13 2008 +0200
+++ b/src/table.cc	Fri Sep 26 16:37:38 2008 +0200
@@ -69,8 +69,8 @@
    else
       style_attrs.borderWidth.setVal (border);
 
-   style_attrs.setBorderColor (Color::createShaded(HT2LT(html),
-                                                   style_attrs.backgroundColor->getColor()));
+   style_attrs.setBorderColor (
+      Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color));
    style_attrs.setBorderStyle (BORDER_OUTSET);
    style_attrs.hBorderSpacing = cellspacing;
    style_attrs.vBorderSpacing = cellspacing;
@@ -93,10 +93,9 @@
       if (bgcolor != -1) {
          if (bgcolor == 0xffffff && !prefs.allow_white_bg)
             bgcolor = prefs.bg_color;
+         S_TOP(html)->current_bg_color = bgcolor;
          style_attrs.backgroundColor =
             Color::createShaded (HT2LT(html), bgcolor);
-         HTML_SET_TOP_ATTR (html, backgroundColor,
-                            Color::createShaded (HT2LT(html), bgcolor));
       }
    }
 
@@ -137,7 +136,8 @@
    const char *attrbuf;
    dw::core::style::StyleAttrs style_attrs;
    dw::core::style::Style *style, *old_style;
-   int32_t bgcolor;
+   int32_t bgcolor = -1;
+   bool new_style = false;
 
 #ifdef USE_TABLES
    switch (S_TOP(html)->table_mode) {
@@ -161,8 +161,7 @@
             style_attrs.backgroundColor =
                Color::createShaded (HT2LT(html), bgcolor);
             style = Style::create (HT2LT(html), &style_attrs);
-            HTML_SET_TOP_ATTR (html, backgroundColor,
-                               Color::createShaded (HT2LT(html), bgcolor));
+            S_TOP(html)->current_bg_color = bgcolor;
          }
       }
 
@@ -176,14 +175,18 @@
       }
 
       style_attrs = *S_TOP(html)->table_cell_style;
-      a_Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs);
-      style_attrs.backgroundColor =
-         Color::createShaded (HT2LT(html),
-                              S_TOP(html)->style->backgroundColor->getColor());
-      old_style = S_TOP(html)->table_cell_style;
-      S_TOP(html)->table_cell_style =
-         Style::create (HT2LT(html), &style_attrs);
-      old_style->unref ();
+      if (bgcolor != -1) {
+         style_attrs.backgroundColor =Color::createShaded(HT2LT(html),bgcolor);
+         new_style = true;
+      }
+      if (a_Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs))
+         new_style = true;
+      if (new_style) {
+         old_style = S_TOP(html)->table_cell_style;
+         S_TOP(html)->table_cell_style =
+            Style::create (HT2LT(html), &style_attrs);
+         old_style->unref ();
+      }
       break;
    default:
       break;
@@ -292,8 +295,7 @@
             new_style = TRUE;
             style_attrs.backgroundColor =
                Color::createShaded (HT2LT(html), bgcolor);
-            HTML_SET_TOP_ATTR (html, backgroundColor,
-                               Color::createShaded (HT2LT(html), bgcolor));
+            S_TOP(html)->current_bg_color = bgcolor;
          }
       }