Bug 170398 - [testcase] Rendering failures with selectboxes if <select> tag contains a "background-image" CSS attribute
Summary: [testcase] Rendering failures with selectboxes if <select> tag contains a "ba...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: 4.1.0
Platform: openSUSE Unspecified
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-04 17:56 UTC by Oliver Becker
Modified: 2008-09-05 03:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Reduced test case (1.30 KB, text/html)
2008-09-04 18:53 UTC, Frank Reininghaus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Becker 2008-09-04 17:56:19 UTC
Version:            (using KDE 4.1.1)
Installed from:    SuSE RPMs

When viewing the pages www.ogame.de or www.ogame.org, the selectboxes are terribly drawn, when opened.
The Selectbox background is erased and the labels overdraw each other when scrolling.
Comment 1 Frank Reininghaus 2008-09-04 18:53:03 UTC
Created attachment 27242 [details]
Reduced test case

Thanks for the bug report. I can confirm this on 4.1.1 and trunk rev. 856793. The problem seems to be the CSS attribute 'style="background-image:url(eingabe_back.png);"' in the <select> tag. If I remove it, the rendering seems to be fine. It does not seem to matter if the background image exists or not (the URL of the background image is http://www.ogame.de/img/eingabe_back.png).
Comment 2 Germain Garand 2008-09-05 03:47:44 UTC
SVN commit 857217 by ggarand:

fix background of the <select> form widget's popup list.

When the form widget has an associated bg image, it is assigned a
partially transparent palette to let the image show through.

That palette used to percolate to the popup list, with interesting visual
results.

BUG: 170398


 M  +32 -2     render_replaced.cpp  


--- trunk/KDE/kdelibs/khtml/rendering/render_replaced.cpp #857216:857217
@@ -410,11 +410,15 @@
         if (!backgroundColor.isValid() && !style()->htmlHacks())
             backgroundColor = QColor(0,0,0,0);
 
-        // check if we have to paint our background and let it show through
+        // check if we have to paint our background and let it show through the widget
         bool trans = ( isRedirectedWidget() && style()->backgroundLayers() && 
                        style()->backgroundLayers()->hasImage() && !qobject_cast<KUrlRequester*>(m_widget) );
 
         QPalette pal(QApplication::palette(m_widget));
+        // We need a non-transparent version for widgets with popups (e.g. kcombobox). The popups must not let
+        // the background show through.
+        QPalette non_trans_pal = pal;
+
         if (color.isValid() || backgroundColor.isValid() || trans) {
             int contrast_ = KGlobalSettings::contrast();
             int highlightVal = 100 + (2*contrast_+4)*16/10;
@@ -428,6 +432,7 @@
                                        (backgroundColor == colorForCSSValue(CSS_VAL_BUTTONFACE)) );
             if (shouldChangeBgPal || trans) {
                 pal.setColor(widget()->backgroundRole(), trans ? QColor(0,0,0,0) : backgroundColor);
+                non_trans_pal.setColor(widget()->backgroundRole(), backgroundColor);
                 for ( int i = 0; i < QPalette::NColorGroups; ++i ) {
                     if (shouldChangeBgPal) {
                         pal.setColor( (QPalette::ColorGroup)i, QPalette::Window, backgroundColor );
@@ -435,9 +440,16 @@
                         pal.setColor( (QPalette::ColorGroup)i, QPalette::Dark, backgroundColor.dark(lowlightVal) );
                         pal.setColor( (QPalette::ColorGroup)i, QPalette::Mid, backgroundColor.dark(120) );
                         pal.setColor( (QPalette::ColorGroup)i, QPalette::Midlight, backgroundColor.light(110) );
+                        non_trans_pal.setColor( (QPalette::ColorGroup)i, QPalette::Window, backgroundColor );
+                        non_trans_pal.setColor( (QPalette::ColorGroup)i, QPalette::Light, backgroundColor.light(highlightVal) );
+                        non_trans_pal.setColor( (QPalette::ColorGroup)i, QPalette::Dark, backgroundColor.dark(lowlightVal) );
+                        non_trans_pal.setColor( (QPalette::ColorGroup)i, QPalette::Mid, backgroundColor.dark(120) );
+                        non_trans_pal.setColor( (QPalette::ColorGroup)i, QPalette::Midlight, backgroundColor.light(110) );
                     }
                     pal.setColor( (QPalette::ColorGroup)i, QPalette::Button, trans ? QColor(0,0,0,0):backgroundColor );
                     pal.setColor( (QPalette::ColorGroup)i, QPalette::Base, trans ? QColor(0,0,0,0):backgroundColor );
+                    non_trans_pal.setColor( (QPalette::ColorGroup)i, QPalette::Button, backgroundColor );
+                    non_trans_pal.setColor( (QPalette::ColorGroup)i, QPalette::Base, backgroundColor );
                 }
             }
             if ( color.isValid() ) {
@@ -457,6 +469,7 @@
                 const ColorSet *set = toSet;
                 while( set->cg != QPalette::NColorGroups ) {
                     pal.setColor( set->cg, set->cr, color );
+                    non_trans_pal.setColor( set->cg, set->cr, color );
                     ++set;
                 }
 
@@ -476,9 +489,26 @@
                pal.setColor(QPalette::Disabled,QPalette::Foreground,disfg);
                pal.setColor(QPalette::Disabled,QPalette::Text,disfg);
                pal.setColor(QPalette::Disabled,QPalette::ButtonText,disfg);
+                non_trans_pal.setColor(QPalette::Disabled,QPalette::Foreground,disfg);
+                non_trans_pal.setColor(QPalette::Disabled,QPalette::Text,disfg);
+                non_trans_pal.setColor(QPalette::Disabled,QPalette::ButtonText,disfg);
             }
         }
-        m_widget->setPalette(pal);    
+        if (qobject_cast<QComboBox*>(m_widget)) {
+            m_widget->setPalette(pal);
+            // mmh great, there's no accessor for the popup... 
+            QList<QWidget*>l = qFindChildren<QWidget *>(m_widget, QString());
+            foreach(QWidget* w, l) {
+                if (qobject_cast<QAbstractScrollArea*>(w)) {
+                    // we have the listview, climb up to reach its container.
+                    assert( w->parentWidget() != m_widget );
+                    if (w->parentWidget())
+                        w->parentWidget()->setPalette(non_trans_pal);
+                }
+            }
+        } else {
+            m_widget->setPalette(pal);
+        }
 
         // Border:
         if (shouldPaintBorder())