aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/form.cc4
-rw-r--r--src/styleengine.cc15
-rw-r--r--src/styleengine.hh2
3 files changed, 18 insertions, 3 deletions
diff --git a/src/form.cc b/src/form.cc
index 9f1a7040..8c6a277a 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -857,7 +857,7 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
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 @@ static Embed *Html_input_image(DilloHtml *html, const char *tag, int tagsize)
/* 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);
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 5c6f0972..d9ec3ff2 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -465,6 +465,21 @@ bool StyleEngine::computeLength (dw::core::style::Length *dest,
}
/**
+ * \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.
diff --git a/src/styleengine.hh b/src/styleengine.hh
index ffa13ac9..a324b419 100644
--- a/src/styleengine.hh
+++ b/src/styleengine.hh
@@ -56,6 +56,7 @@ class StyleEngine : public Doctree {
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 @@ class StyleEngine : public Doctree {
else
return wordStyle0 ();
};
-
};
#endif