2011-03-27 Andreas Kling <kling@webkit.org>

        Reviewed by Kenneth Rohde Christiansen.

        [Qt] Support for CSS color and background-color properties on select element's dropdown list
        https://bugs.webkit.org/show_bug.cgi?id=51627

        Extend the QWebSelectData interface with background and foreground colors
        for the whole menu, as well as per-item. Hook it up to the PopupMenuStyle
        getters in RenderMenuList.

        * Api/qwebkitplatformplugin.h:
        * WebCoreSupport/PopupMenuQt.cpp:
        (SelectData::backgroundColor):
        (SelectData::foregroundColor):
        (SelectData::itemBackgroundColor):
        (SelectData::itemForegroundColor):
        * WebCoreSupport/QtFallbackWebPopup.cpp:
        (WebCore::QtFallbackWebPopup::show):
        (WebCore::QtFallbackWebPopup::populate):


git-svn-id: svn://svn.chromium.org/blink/trunk@82075 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0d93d33e
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* and may be changed from version to version or even be completely removed. * and may be changed from version to version or even be completely removed.
*/ */
#include <QColor>
#include <QObject> #include <QObject>
#include <QUrl> #include <QUrl>
#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA #if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
...@@ -46,6 +47,10 @@ public: ...@@ -46,6 +47,10 @@ public:
virtual bool itemIsSelected(int index) const = 0; virtual bool itemIsSelected(int index) const = 0;
virtual int itemCount() const = 0; virtual int itemCount() const = 0;
virtual bool multiple() const = 0; virtual bool multiple() const = 0;
virtual QColor backgroundColor() const = 0;
virtual QColor foregroundColor() const = 0;
virtual QColor itemBackgroundColor(int index) const = 0;
virtual QColor itemForegroundColor(int index) const = 0;
}; };
class QWebSelectMethod : public QObject class QWebSelectMethod : public QObject
......
2011-03-27 Andreas Kling <kling@webkit.org>
Reviewed by Kenneth Rohde Christiansen.
[Qt] Support for CSS color and background-color properties on select element's dropdown list
https://bugs.webkit.org/show_bug.cgi?id=51627
Extend the QWebSelectData interface with background and foreground colors
for the whole menu, as well as per-item. Hook it up to the PopupMenuStyle
getters in RenderMenuList.
* Api/qwebkitplatformplugin.h:
* WebCoreSupport/PopupMenuQt.cpp:
(SelectData::backgroundColor):
(SelectData::foregroundColor):
(SelectData::itemBackgroundColor):
(SelectData::itemForegroundColor):
* WebCoreSupport/QtFallbackWebPopup.cpp:
(WebCore::QtFallbackWebPopup::show):
(WebCore::QtFallbackWebPopup::populate):
2011-03-27 Yi Shen <yi.4.shen@nokia.com> 2011-03-27 Yi Shen <yi.4.shen@nokia.com>
Reviewed by Andreas Kling. Reviewed by Andreas Kling.
......
...@@ -44,6 +44,10 @@ public: ...@@ -44,6 +44,10 @@ public:
virtual int itemCount() const { return d ? d->listSize() : 0; } virtual int itemCount() const { return d ? d->listSize() : 0; }
virtual bool itemIsSelected(int idx) const { return d ? d->itemIsSelected(idx) : false; } virtual bool itemIsSelected(int idx) const { return d ? d->itemIsSelected(idx) : false; }
virtual bool multiple() const; virtual bool multiple() const;
virtual QColor backgroundColor() const { return d ? QColor(d->menuStyle().backgroundColor()) : QColor(); }
virtual QColor foregroundColor() const { return d ? QColor(d->menuStyle().foregroundColor()) : QColor(); }
virtual QColor itemBackgroundColor(int idx) const { return d ? QColor(d->itemStyle(idx).backgroundColor()) : QColor(); }
virtual QColor itemForegroundColor(int idx) const { return d ? QColor(d->itemStyle(idx).foregroundColor()) : QColor(); }
private: private:
WebCore::PopupMenuClient*& d; WebCore::PopupMenuClient*& d;
......
...@@ -124,6 +124,17 @@ void QtFallbackWebPopup::show(const QWebSelectData& data) ...@@ -124,6 +124,17 @@ void QtFallbackWebPopup::show(const QWebSelectData& data)
populate(data); populate(data);
QColor backgroundColor = data.backgroundColor();
QColor foregroundColor = data.foregroundColor();
QPalette palette = m_combo->palette();
if (backgroundColor.isValid())
palette.setColor(QPalette::Background, backgroundColor);
if (foregroundColor.isValid())
palette.setColor(QPalette::Foreground, foregroundColor);
m_combo->setPalette(palette);
QRect rect = geometry(); QRect rect = geometry();
if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(pageClient()->pluginParent())) { if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(pageClient()->pluginParent())) {
QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget(webView); QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget(webView);
...@@ -235,6 +246,8 @@ void QtFallbackWebPopup::populate(const QWebSelectData& data) ...@@ -235,6 +246,8 @@ void QtFallbackWebPopup::populate(const QWebSelectData& data)
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
model->item(i)->setToolTip(data.itemToolTip(i)); model->item(i)->setToolTip(data.itemToolTip(i));
#endif #endif
model->item(i)->setBackground(data.itemBackgroundColor(i));
model->item(i)->setForeground(data.itemForegroundColor(i));
if (data.itemIsSelected(i)) if (data.itemIsSelected(i))
currentIndex = i; currentIndex = i;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment