changeset 956:dd46fa6ceb94

fix missing background color for ComplexButton (noticed by corvid)
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Tue, 17 Feb 2009 11:57:06 +0100
parents b84781690627
children bd699ba9a469
files src/form.cc src/styleengine.cc src/styleengine.hh
diffstat 3 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/form.cc	Tue Feb 17 10:22:06 2009 +0100
+++ b/src/form.cc	Tue Feb 17 11:57:06 2009 +0100
@@ -857,7 +857,7 @@
       char *name, *value;
 
       page = new Textblock (prefs.limit_text_width);
-      page->setStyle (html->styleEngine->style ());
+      page->setStyle (html->styleEngine->backgroundStyle ());
 
       ResourceFactory *factory = HT2LT(html)->getResourceFactory();
       Resource *resource = factory->createComplexButtonResource(page, true);
@@ -1912,7 +1912,7 @@
 
       /* create new image and add it to the button */
       if ((Image = a_Html_image_new(html, tag, tagsize, url))) {
-         IM2DW(Image)->setStyle (html->styleEngine->style ());
+         IM2DW(Image)->setStyle (html->styleEngine->backgroundStyle ());
          ResourceFactory *factory = HT2LT(html)->getResourceFactory();
          ComplexButtonResource *complex_b_r =
             factory->createComplexButtonResource(IM2DW(Image), false);
--- a/src/styleengine.cc	Tue Feb 17 10:22:06 2009 +0100
+++ b/src/styleengine.cc	Tue Feb 17 11:57:06 2009 +0100
@@ -465,6 +465,21 @@
 }
 
 /**
+ * \brief Similar to StyleEngine::style(), but with backgroundColor set.
+ * A normal style might have backgroundColor == NULL to indicate a transparent
+ * background. This method ensures that backgroundColor is set.
+ */ 
+Style * StyleEngine::backgroundStyle () {
+   StyleAttrs attrs = *style ();
+   
+   for (int i = stack->size () - 1; i >= 0 && ! attrs.backgroundColor; i--)
+      attrs.backgroundColor = stack->getRef (i)->style->backgroundColor;
+
+   assert (attrs.backgroundColor);
+   return Style::create (layout, &attrs);
+}
+
+/**
  * \brief Create a new style object based on the previously opened / closed
  *    HTML elements and the nonCssProperties that have been set.
  *    This method is private. Call style() to get a current style object.
--- a/src/styleengine.hh	Tue Feb 17 10:22:06 2009 +0100
+++ b/src/styleengine.hh	Tue Feb 17 11:57:06 2009 +0100
@@ -56,6 +56,7 @@
       void setPseudoVisited ();
       void setNonCssHints (CssPropertyList *nonCssHints);
       void inheritBackgroundColor (); /* \todo get rid of this somehow */
+      dw::core::style::Style *backgroundStyle ();
 
       inline dw::core::style::Style *style () {
          dw::core::style::Style *s = stack->getRef (stack->size () - 1)->style;
@@ -71,7 +72,6 @@
          else
             return wordStyle0 ();
       };
-
 };
 
 #endif