Bug 26045 - The Qt Style Sheets are not applied on webkit scrollbars
Summary: The Qt Style Sheets are not applied on webkit scrollbars
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P3 Enhancement
Assignee: Nobody
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2009-05-27 13:44 PDT by Vincent Ordy
Modified: 2014-02-03 03:50 PST (History)
1 user (show)

See Also:


Attachments
Testcase (1.02 KB, application/x-bzip2)
2010-03-10 15:25 PST, Vincent Ordy
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Ordy 2009-05-27 13:44:31 PDT
The Qt Style Sheets set with setStyleSheet() on the QWebView are not applied on webkit scroll bars.

It seems to happen because of the QStyleSheetStyleSelector::attribute() and QStyleSheetStyleSelector::nodeNames() functions used by StyleSelector::styleRulesForNode(). They both use the widget metadata to get the widget type name and properties in order to find out which rules to apply.

A quick fix is to have ScrollbarThemeQt inherit from QScrollbar and use "this" as widget for drawComplexControl().
-    p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
+    p.style->drawComplexControl(QStyle::CC_ScrollBar, opt, p.painter, this);
Comment 1 Kent Hansen 2010-03-10 07:40:06 PST
Please provide a testcase (in the form of a compileable Qt app, for example).
Comment 2 Vincent Ordy 2010-03-10 15:25:58 PST
Created attachment 50446 [details]
Testcase
Comment 3 Vincent Ordy 2010-03-10 15:40:11 PST
This testcase creates 2 windows.  Both have a QScrollArea which contains a QWebView. I do setStyleSheet("QScrollBar { background: blue; }") on both windows.

The style of the first is QWindowsStyle, and the second's is QMotifStyle. The QWebView scrollbar does use the style set by setStyle.

However, it does not use the one set by setStyleSheet("QScrollBar {...}"). Like I said before, it happens because the Qt Style Sheets system uses metadata to find out the type of an object. Since a ScrollbarThemeQt is not a QScrollbar, the style sheet for QScrollbar is not used.
Comment 4 Kent Hansen 2010-03-12 03:23:47 PST
(In reply to comment #3)
> This testcase creates 2 windows.  Both have a QScrollArea which contains a
> QWebView. I do setStyleSheet("QScrollBar { background: blue; }") on both
> windows.
> 
> The style of the first is QWindowsStyle, and the second's is QMotifStyle. The
> QWebView scrollbar does use the style set by setStyle.
> 
> However, it does not use the one set by setStyleSheet("QScrollBar {...}"). Like
> I said before, it happens because the Qt Style Sheets system uses metadata to
> find out the type of an object. Since a ScrollbarThemeQt is not a QScrollbar,
> the style sheet for QScrollbar is not used.

Thanks for the testcase.
Hmm, with r33755 and Qt 4.6 trunk the QWebView scrollbars don't even respect setStyle()! It did in an older version, like you said, so this is a regression.
Comment 5 Kent Hansen 2010-03-12 03:24:37 PST
(In reply to comment #4)
> Hmm, with r33755 and Qt 4.6 trunk

Sorry, that should be r55658.
Comment 6 Jocelyn Turcotte 2014-02-03 03:50:33 PST
=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.