[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andreas.kling at nokia.com
andreas.kling at nokia.com
Wed Dec 22 14:01:33 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit d940a576c57bbc30311c75422856930ff48890f0
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Oct 1 13:52:33 2010 +0000
2010-10-01 Ragner Magalhaes <ragner.magalhaes at openbossa.org>
Reviewed by Kenneth Rohde Christiansen.
[Qt] New buttons style for Qt Mobile theme
https://bugs.webkit.org/show_bug.cgi?id=46920
Rename Maemo5Webstyle to QtMobileWebStyle since it implements the style for all Qt mobile platform.
Adjust new Qt mobile style for buttons, radios, checks and combos.
* WebCore.pro:
* css/themeQtMobile.css: Adjust gradient color for buttons and combos.
(select):
(select:active):
* platform/qt/QtMobileWebStyle.cpp: Renamed from platform/qt/Maemo5Webstyle.cpp to match name scheme.
(QtMobileWebStyle::QtMobileWebStyle):
(drawRectangularControlBackground):
(QtMobileWebStyle::drawChecker):
(QtMobileWebStyle::findChecker):
(QtMobileWebStyle::drawRadio): Adjust gradient color for RadioButton.
(QtMobileWebStyle::findRadio):
(QtMobileWebStyle::drawControl): Adjust gradient color for CheckBox.
(QtMobileWebStyle::drawMultipleComboButton):
(QtMobileWebStyle::drawSimpleComboButton): Adjust ComboBox arrow.
(QtMobileWebStyle::getButtonImageSize):
(QtMobileWebStyle::findComboButton):
(QtMobileWebStyle::drawComplexControl):
* platform/qt/QtMobileWebStyle.h: Renamed from platform/qt/Maemo5Webstyle.h to match name scheme.
* platform/qt/RenderThemeQt.cpp:
(WebCore::RenderThemeQt::RenderThemeQt):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68889 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4682cc8..3b85164 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-10-01 Ragner Magalhaes <ragner.magalhaes at openbossa.org>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] New buttons style for Qt Mobile theme
+ https://bugs.webkit.org/show_bug.cgi?id=46920
+
+ Rename Maemo5Webstyle to QtMobileWebStyle since it implements the style for all Qt mobile platform.
+ Adjust new Qt mobile style for buttons, radios, checks and combos.
+
+ * WebCore.pro:
+ * css/themeQtMobile.css: Adjust gradient color for buttons and combos.
+ (select):
+ (select:active):
+ * platform/qt/QtMobileWebStyle.cpp: Renamed from platform/qt/Maemo5Webstyle.cpp to match name scheme.
+ (QtMobileWebStyle::QtMobileWebStyle):
+ (drawRectangularControlBackground):
+ (QtMobileWebStyle::drawChecker):
+ (QtMobileWebStyle::findChecker):
+ (QtMobileWebStyle::drawRadio): Adjust gradient color for RadioButton.
+ (QtMobileWebStyle::findRadio):
+ (QtMobileWebStyle::drawControl): Adjust gradient color for CheckBox.
+ (QtMobileWebStyle::drawMultipleComboButton):
+ (QtMobileWebStyle::drawSimpleComboButton): Adjust ComboBox arrow.
+ (QtMobileWebStyle::getButtonImageSize):
+ (QtMobileWebStyle::findComboButton):
+ (QtMobileWebStyle::drawComplexControl):
+ * platform/qt/QtMobileWebStyle.h: Renamed from platform/qt/Maemo5Webstyle.h to match name scheme.
+ * platform/qt/RenderThemeQt.cpp:
+ (WebCore::RenderThemeQt::RenderThemeQt):
+
2010-10-01 Andrey Kosyakov <caseq at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 1847d09..45e09ea 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -2671,8 +2671,8 @@ SOURCES += \
contains(DEFINES, WTF_USE_QT_MOBILE_THEME=1) {
- HEADERS += platform/qt/Maemo5Webstyle.h
- SOURCES += platform/qt/Maemo5Webstyle.cpp
+ HEADERS += platform/qt/QtMobileWebStyle.h
+ SOURCES += platform/qt/QtMobileWebStyle.cpp
}
maemo5 {
diff --git a/WebCore/css/themeQtMobile.css b/WebCore/css/themeQtMobile.css
index ef2d182..5cc39c8 100644
--- a/WebCore/css/themeQtMobile.css
+++ b/WebCore/css/themeQtMobile.css
@@ -31,9 +31,10 @@ input[type="reset"],
input[type="file"]::-webkit-file-upload-button, button,
select {
padding: 2px 18px 3px 18px;
- border: 1px solid black;
+ border: 1px solid gray;
-webkit-border-radius:5px;
- background-color: ButtonFace;
+ background: -webkit-gradient(linear, left bottom, left top, color-stop(0.0, #e5e5e5), color-stop(0.4, #ffffff));
+ color: #3e3e3e;
}
input[type="button"]:disabled,
@@ -50,8 +51,8 @@ input[type="submit"]:active,
input[type="reset"]:active,
input[type="file"]:active::-webkit-file-upload-button,
button:active,
-select:active{
- background-color: ButtonShadow;
+select:active {
+ background: ButtonShadow;
}
input[type="button"]:active:disabled,
diff --git a/WebCore/platform/qt/Maemo5Webstyle.cpp b/WebCore/platform/qt/Maemo5Webstyle.cpp
deleted file mode 100644
index 42b0b71..0000000
--- a/WebCore/platform/qt/Maemo5Webstyle.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-#include "config.h"
-#include "Maemo5Webstyle.h"
-
-#include "QtStyleOptionWebComboBox.h"
-
-#include <QPainter>
-#include <QPixmapCache>
-#include <QStyleOption>
-
-Maemo5WebStyle::Maemo5WebStyle()
-{
-}
-
-static inline void drawRectangularControlBackground(QPainter* painter, const QPen& pen, const QRect& rect, const QBrush& brush)
-{
- QPen oldPen = painter->pen();
- QBrush oldBrush = painter->brush();
- painter->setPen(pen);
- painter->setBrush(brush);
-
- int line = 1;
- painter->drawRect(rect.adjusted(line, line, -line, -line));
-
- painter->setPen(oldPen);
- painter->setBrush(oldBrush);
-}
-
-void Maemo5WebStyle::drawChecker(QPainter* painter, int size, QColor color) const
-{
- int border = qMin(qMax(1, int(0.2 * size)), 6);
- int checkerSize = size - 2 * border;
- int width = checkerSize / 3;
- int middle = qMax(3 * checkerSize / 7, 3);
- int x = ((size - checkerSize) >> 1);
- int y = ((size - checkerSize) >> 1) + (checkerSize - width - middle);
- QVector<QLineF> lines(checkerSize + 1);
- painter->setPen(color);
- for (int i = 0; i < middle; ++i) {
- lines[i] = QLineF(x, y, x, y + width);
- ++x;
- ++y;
- }
- for (int i = middle; i <= checkerSize; ++i) {
- lines[i] = QLineF(x, y, x, y + width);
- ++x;
- --y;
- }
- painter->drawLines(lines.constData(), lines.size());
-}
-
-QPixmap Maemo5WebStyle::findChecker(const QRect& rect, bool disabled) const
-{
- int size = qMin(rect.width(), rect.height());
- QPixmap result;
- static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-checker-";
- QString key = prefix + QString::number(size) + "-" + (disabled ? "disabled" : "enabled");
- if (!QPixmapCache::find(key, result)) {
- result = QPixmap(size, size);
- result.fill(Qt::transparent);
- QPainter painter(&result);
- drawChecker(&painter, size, disabled ? Qt::gray : Qt::black);
- QPixmapCache::insert(key, result);
- }
- return result;
-}
-
-void Maemo5WebStyle::drawRadio(QPainter* painter, const QSize& size, bool checked, QColor color) const
-{
- painter->setRenderHint(QPainter::Antialiasing, true);
-
- // deflate one pixel
- QRect rect = QRect(QPoint(1, 1), QSize(size.width() - 2, size.height() - 2));
-
- QPen pen(Qt::black);
- pen.setWidth(1);
- painter->setPen(color);
- painter->setBrush(Qt::white);
- painter->drawEllipse(rect);
- int border = 0.1 * (rect.width() + rect.height());
- border = qMin(qMax(2, border), 10);
- rect.adjust(border, border, -border, -border);
- if (checked) {
- painter->setPen(Qt::NoPen);
- painter->setBrush(color);
- painter->drawEllipse(rect);
- }
-}
-
-QPixmap Maemo5WebStyle::findRadio(const QSize& size, bool checked, bool disabled) const
-{
- QPixmap result;
- static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-radio-";
- QString key = prefix + QString::number(size.width()) + "-" + QString::number(size.height()) +
- + "-" + (disabled ? "disabled" : "enabled") + (checked ? "-checked" : "");
- if (!QPixmapCache::find(key, result)) {
- result = QPixmap(size);
- result.fill(Qt::transparent);
- QPainter painter(&result);
- drawRadio(&painter, size, checked, disabled ? Qt::gray : Qt::black);
- QPixmapCache::insert(key, result);
- }
- return result;
-}
-
-void Maemo5WebStyle::drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
-{
- switch (element) {
- case CE_CheckBox: {
- QRect rect = option->rect;
- const bool disabled = !(option->state & State_Enabled);
- drawRectangularControlBackground(painter, QPen(disabled ? Qt::gray : Qt::black), rect, option->palette.base());
- rect.adjust(1, 1, -1, -1);
-
- if (option->state & State_Off)
- break;
-
- QPixmap checker = findChecker(rect, disabled);
- if (checker.isNull())
- break;
-
- int x = (rect.width() - checker.width()) >> 1;
- int y = (rect.height() - checker.height()) >> 1;
- painter->drawPixmap(rect.x() + x, rect.y() + y, checker);
- break;
- }
- case CE_RadioButton: {
- const bool disabled = !(option->state & State_Enabled);
- QPixmap radio = findRadio(option->rect.size(), option->state & State_On, disabled);
- if (radio.isNull())
- break;
- painter->drawPixmap(option->rect.x(), option->rect.y(), radio);
- break;
- }
- default:
- QWindowsStyle::drawControl(element, option, painter, widget);
- }
-}
-
-void Maemo5WebStyle::drawMultipleComboButton(QPainter* painter, const QSize& size, QColor color) const
-{
- int rectWidth = size.width() - 1;
- int width = qMax(2, rectWidth >> 3);
- int distance = (rectWidth - 3 * width) >> 1;
- int top = (size.height() - width) >> 1;
-
- painter->setPen(color);
- painter->setBrush(color);
-
- painter->drawRect(0, top, width, width);
- painter->drawRect(width + distance, top, width, width);
- painter->drawRect(2 * (width + distance), top, width, width);
-}
-
-void Maemo5WebStyle::drawSimpleComboButton(QPainter* painter, const QSize& size, QColor color) const
-{
- QPolygon polygon;
- int width = size.width();
- polygon.setPoints(3, 0, 0, width - 1, 0, width >> 1, size.height());
- painter->setPen(color);
- painter->setBrush(color);
- painter->drawPolygon(polygon);
-}
-
-QSize Maemo5WebStyle::getButtonImageSize(const QSize& buttonSize) const
-{
- const int border = qMax(3, buttonSize.width() >> 3) << 1;
-
- int width = buttonSize.width() - border;
- int height = buttonSize.height() - border;
-
- if (width < 0 || height < 0)
- return QSize();
-
- if (height >= (width >> 1))
- width = width >> 1 << 1;
- else
- width = height << 1;
-
- return QSize(width + 1, width >> 1);
-}
-
-QPixmap Maemo5WebStyle::findComboButton(const QSize& size, bool multiple, bool disabled) const
-{
- QPixmap result;
- QSize imageSize = getButtonImageSize(size);
-
- if (imageSize.isNull())
- return QPixmap();
- static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-combo-";
- QString key = prefix + (multiple ? "multiple-" : "simple-") +
- QString::number(imageSize.width()) + "-" + QString::number(imageSize.height()) +
- + "-" + (disabled ? "disabled" : "enabled");
- if (!QPixmapCache::find(key, result)) {
- result = QPixmap(imageSize);
- result.fill(Qt::transparent);
- QPainter painter(&result);
- if (multiple)
- drawMultipleComboButton(&painter, imageSize, disabled ? Qt::gray : Qt::black);
- else
- drawSimpleComboButton(&painter, imageSize, disabled ? Qt::gray : Qt::black);
- QPixmapCache::insert(key, result);
- }
- return result;
-}
-
-void Maemo5WebStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const
-{
- switch (control) {
- case CC_ComboBox: {
-
- bool multiple = false;
- const bool disabled = !(option->state & State_Enabled);
-
- const QStyleOptionComboBox* cmb = 0;
- const WebCore::QtStyleOptionWebComboBox* webCombo = static_cast<const WebCore::QtStyleOptionWebComboBox*>(option);
-
- if (webCombo) {
- multiple = webCombo->multiple();
- cmb = webCombo;
- } else
- cmb = qstyleoption_cast<const QStyleOptionComboBox*>(option);
-
- if (!cmb) {
- QWindowsStyle::drawComplexControl(control, option, painter, widget);
- break;
- }
-
- if (!(cmb->subControls & SC_ComboBoxArrow))
- break;
-
- QRect rect = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
- QPixmap pic = findComboButton(rect.size(), multiple, disabled);
-
- if (pic.isNull())
- break;
-
- int x = (rect.width() - pic.width()) >> 1;
- int y = (rect.height() - pic.height()) >> 1;
- painter->drawPixmap(rect.x() + x, rect.y() + y, pic);
-
- painter->setPen(disabled ? Qt::gray : Qt::darkGray);
- painter->drawLine(rect.left() - 2, rect.top() + 2, rect.left() - 2, rect.bottom() - 2);
-
- break;
- }
- default:
- QWindowsStyle::drawComplexControl(control, option, painter, widget);
- }
-}
diff --git a/WebCore/platform/qt/Maemo5Webstyle.h b/WebCore/platform/qt/Maemo5Webstyle.h
deleted file mode 100644
index ce717b6..0000000
--- a/WebCore/platform/qt/Maemo5Webstyle.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef Maemo5Webstyle_h
-#define Maemo5Webstyle_h
-
-#include <QWindowsStyle>
-
-class Maemo5WebStyle : public QWindowsStyle {
-public:
- Maemo5WebStyle();
-
- void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = 0) const;
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget = 0) const;
-
-private:
- void drawChecker(QPainter* painter, int size, QColor color) const;
- QPixmap findChecker(const QRect& rect, bool disabled) const;
-
- void drawRadio(QPainter* painter, const QSize& size, bool checked, QColor color) const;
- QPixmap findRadio(const QSize& size, bool checked, bool disabled) const;
-
- QSize getButtonImageSize(const QSize& buttonSize) const;
- void drawSimpleComboButton(QPainter* painter, const QSize& size, QColor color) const;
- void drawMultipleComboButton(QPainter* painter, const QSize& size, QColor color) const;
- QPixmap findComboButton(const QSize& size, bool multiple, bool disabled) const;
-
-};
-
-#endif // Maemo5WebStyle_h
diff --git a/WebCore/platform/qt/QtMobileWebStyle.cpp b/WebCore/platform/qt/QtMobileWebStyle.cpp
new file mode 100644
index 0000000..0748320
--- /dev/null
+++ b/WebCore/platform/qt/QtMobileWebStyle.cpp
@@ -0,0 +1,293 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#include "config.h"
+#include "QtMobileWebStyle.h"
+
+#include "QtStyleOptionWebComboBox.h"
+
+#include <QPainter>
+#include <QPixmapCache>
+#include <QStyleOption>
+
+QtMobileWebStyle::QtMobileWebStyle()
+{
+}
+
+static inline void drawRectangularControlBackground(QPainter* painter, const QPen& pen, const QRect& rect, const QBrush& brush)
+{
+ QPen oldPen = painter->pen();
+ QBrush oldBrush = painter->brush();
+ painter->setPen(pen);
+ painter->setBrush(brush);
+
+ int line = 1;
+ painter->drawRect(rect.adjusted(line, line, -line, -line));
+
+ painter->setPen(oldPen);
+ painter->setBrush(oldBrush);
+}
+
+void QtMobileWebStyle::drawChecker(QPainter* painter, int size, QColor color) const
+{
+ int border = qMin(qMax(1, int(0.2 * size)), 6);
+ int checkerSize = size - 2 * border;
+ int width = checkerSize / 3;
+ int middle = qMax(3 * checkerSize / 7, 3);
+ int x = ((size - checkerSize) >> 1);
+ int y = ((size - checkerSize) >> 1) + (checkerSize - width - middle);
+ QVector<QLineF> lines(checkerSize + 1);
+ painter->setPen(color);
+ for (int i = 0; i < middle; ++i) {
+ lines[i] = QLineF(x, y, x, y + width);
+ ++x;
+ ++y;
+ }
+ for (int i = middle; i <= checkerSize; ++i) {
+ lines[i] = QLineF(x, y, x, y + width);
+ ++x;
+ --y;
+ }
+ painter->drawLines(lines.constData(), lines.size());
+}
+
+QPixmap QtMobileWebStyle::findChecker(const QRect& rect, bool disabled) const
+{
+ int size = qMin(rect.width(), rect.height());
+ QPixmap result;
+ static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-checker-";
+ QString key = prefix + QString::number(size) + "-" + (disabled ? "disabled" : "enabled");
+ if (!QPixmapCache::find(key, result)) {
+ result = QPixmap(size, size);
+ result.fill(Qt::transparent);
+ QPainter painter(&result);
+ drawChecker(&painter, size, disabled ? Qt::lightGray : Qt::darkGray);
+ QPixmapCache::insert(key, result);
+ }
+ return result;
+}
+
+void QtMobileWebStyle::drawRadio(QPainter* painter, const QSize& size, bool checked, QColor color) const
+{
+ painter->setRenderHint(QPainter::Antialiasing, true);
+
+ // deflate one pixel
+ QRect rect = QRect(QPoint(1, 1), QSize(size.width() - 2, size.height() - 2));
+ const QPoint centerGradient(rect.bottomRight() * 0.7);
+
+ QRadialGradient radialGradient(centerGradient, centerGradient.x() - 1);
+ radialGradient.setColorAt(0.0, Qt::white);
+ radialGradient.setColorAt(0.6, Qt::white);
+ radialGradient.setColorAt(1.0, color);
+
+ painter->setPen(color);
+ painter->setBrush(color);
+ painter->drawEllipse(rect);
+ painter->setBrush(radialGradient);
+ painter->drawEllipse(rect);
+
+ int border = 0.1 * (rect.width() + rect.height());
+ border = qMin(qMax(2, border), 10);
+ rect.adjust(border, border, -border, -border);
+ if (checked) {
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(color);
+ painter->drawEllipse(rect);
+ }
+}
+
+QPixmap QtMobileWebStyle::findRadio(const QSize& size, bool checked, bool disabled) const
+{
+ QPixmap result;
+ static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-radio-";
+ QString key = prefix + QString::number(size.width()) + "-" + QString::number(size.height()) +
+ + "-" + (disabled ? "disabled" : "enabled") + (checked ? "-checked" : "");
+ if (!QPixmapCache::find(key, result)) {
+ result = QPixmap(size);
+ result.fill(Qt::transparent);
+ QPainter painter(&result);
+ drawRadio(&painter, size, checked, disabled ? Qt::lightGray : Qt::darkGray);
+ QPixmapCache::insert(key, result);
+ }
+ return result;
+}
+
+void QtMobileWebStyle::drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
+{
+ switch (element) {
+ case CE_CheckBox: {
+ QRect rect = option->rect;
+ const bool disabled = !(option->state & State_Enabled);
+
+ QLinearGradient linearGradient(rect.topLeft(), rect.bottomLeft());
+ if (disabled) {
+ linearGradient.setColorAt(0.0, Qt::lightGray);
+ linearGradient.setColorAt(0.5, Qt::white);
+ } else {
+ linearGradient.setColorAt(0.0, Qt::darkGray);
+ linearGradient.setColorAt(0.5, Qt::white);
+ }
+
+ drawRectangularControlBackground(painter, QPen(disabled ? Qt::lightGray : Qt::darkGray), rect, linearGradient);
+ rect.adjust(1, 1, -1, -1);
+
+ if (option->state & State_Off)
+ break;
+
+ QPixmap checker = findChecker(rect, disabled);
+ if (checker.isNull())
+ break;
+
+ int x = (rect.width() - checker.width()) >> 1;
+ int y = (rect.height() - checker.height()) >> 1;
+ painter->drawPixmap(rect.x() + x, rect.y() + y, checker);
+ break;
+ }
+ case CE_RadioButton: {
+ const bool disabled = !(option->state & State_Enabled);
+ QPixmap radio = findRadio(option->rect.size(), option->state & State_On, disabled);
+ if (radio.isNull())
+ break;
+ painter->drawPixmap(option->rect.x(), option->rect.y(), radio);
+ break;
+ }
+ default:
+ QWindowsStyle::drawControl(element, option, painter, widget);
+ }
+}
+
+void QtMobileWebStyle::drawMultipleComboButton(QPainter* painter, const QSize& size, QColor color) const
+{
+ int rectWidth = size.width() - 1;
+ int width = qMax(2, rectWidth >> 3);
+ int distance = (rectWidth - 3 * width) >> 1;
+ int top = (size.height() - width) >> 1;
+
+ painter->setPen(color);
+ painter->setBrush(color);
+
+ painter->drawRect(0, top, width, width);
+ painter->drawRect(width + distance, top, width, width);
+ painter->drawRect(2 * (width + distance), top, width, width);
+}
+
+void QtMobileWebStyle::drawSimpleComboButton(QPainter* painter, const QSize& size, QColor color) const
+{
+ int width = size.width();
+ int midle = width >> 1;
+ QVector<QLine> lines(width + 1);
+
+ for (int x = 0, y = 0; x < midle; x++, y++) {
+ lines[x] = QLine(x, y, x, y + 2);
+ lines[x + midle] = QLine(width - x - 1, y, width - x - 1, y + 2);
+ }
+ // Just to ensure the lines' intersection.
+ lines[width] = QLine(midle, midle, midle, midle + 2);
+
+ painter->setPen(color);
+ painter->setBrush(color);
+ painter->drawLines(lines);
+}
+
+QSize QtMobileWebStyle::getButtonImageSize(const QSize& buttonSize) const
+{
+ const int border = qMax(3, buttonSize.width() >> 3) << 1;
+
+ int width = buttonSize.width() - border;
+ int height = buttonSize.height() - border;
+
+ if (width < 0 || height < 0)
+ return QSize();
+
+ if (height >= (width >> 1))
+ width = width >> 1 << 1;
+ else
+ width = height << 1;
+
+ return QSize(width + 1, width);
+}
+
+QPixmap QtMobileWebStyle::findComboButton(const QSize& size, bool multiple, bool disabled) const
+{
+ QPixmap result;
+ QSize imageSize = getButtonImageSize(size);
+
+ if (imageSize.isNull())
+ return QPixmap();
+ static const QString prefix = "$qt-maemo5-" + QLatin1String(metaObject()->className()) + "-combo-";
+ QString key = prefix + (multiple ? "multiple-" : "simple-") +
+ QString::number(imageSize.width()) + "-" + QString::number(imageSize.height()) +
+ + "-" + (disabled ? "disabled" : "enabled");
+ if (!QPixmapCache::find(key, result)) {
+ result = QPixmap(imageSize);
+ result.fill(Qt::transparent);
+ QPainter painter(&result);
+ if (multiple)
+ drawMultipleComboButton(&painter, imageSize, disabled ? Qt::lightGray : Qt::darkGray);
+ else
+ drawSimpleComboButton(&painter, imageSize, disabled ? Qt::lightGray : Qt::darkGray);
+ QPixmapCache::insert(key, result);
+ }
+ return result;
+}
+
+void QtMobileWebStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const
+{
+ switch (control) {
+ case CC_ComboBox: {
+
+ bool multiple = false;
+ const bool disabled = !(option->state & State_Enabled);
+
+ const QStyleOptionComboBox* cmb = 0;
+ const WebCore::QtStyleOptionWebComboBox* webCombo = static_cast<const WebCore::QtStyleOptionWebComboBox*>(option);
+
+ if (webCombo) {
+ multiple = webCombo->multiple();
+ cmb = webCombo;
+ } else
+ cmb = qstyleoption_cast<const QStyleOptionComboBox*>(option);
+
+ if (!cmb) {
+ QWindowsStyle::drawComplexControl(control, option, painter, widget);
+ break;
+ }
+
+ if (!(cmb->subControls & SC_ComboBoxArrow))
+ break;
+
+ QRect rect = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
+ QPixmap pic = findComboButton(rect.size(), multiple, disabled);
+
+ if (pic.isNull())
+ break;
+
+ int x = (rect.width() - pic.width()) >> 1;
+ int y = (rect.height() - pic.height()) >> 1;
+ painter->drawPixmap(rect.x() + x, rect.y() + y, pic);
+
+ painter->setPen(disabled ? Qt::gray : Qt::darkGray);
+ painter->drawLine(rect.left() - 2, rect.top() + 2, rect.left() - 2, rect.bottom() - 2);
+
+ break;
+ }
+ default:
+ QWindowsStyle::drawComplexControl(control, option, painter, widget);
+ }
+}
diff --git a/WebCore/platform/qt/QtMobileWebStyle.h b/WebCore/platform/qt/QtMobileWebStyle.h
new file mode 100644
index 0000000..779bd26
--- /dev/null
+++ b/WebCore/platform/qt/QtMobileWebStyle.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef QtMobileWebStyle_h
+#define QtMobileWebStyle_h
+
+#include <QWindowsStyle>
+
+class QtMobileWebStyle : public QWindowsStyle {
+public:
+ QtMobileWebStyle();
+
+ void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = 0) const;
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget = 0) const;
+
+private:
+ void drawChecker(QPainter* painter, int size, QColor color) const;
+ QPixmap findChecker(const QRect& rect, bool disabled) const;
+
+ void drawRadio(QPainter* painter, const QSize& size, bool checked, QColor color) const;
+ QPixmap findRadio(const QSize& size, bool checked, bool disabled) const;
+
+ QSize getButtonImageSize(const QSize& buttonSize) const;
+ void drawSimpleComboButton(QPainter* painter, const QSize& size, QColor color) const;
+ void drawMultipleComboButton(QPainter* painter, const QSize& size, QColor color) const;
+ QPixmap findComboButton(const QSize& size, bool multiple, bool disabled) const;
+
+};
+
+#endif // QtMobileWebStyle_h
diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp
index 7388b76..5909d4a 100644
--- a/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/WebCore/platform/qt/RenderThemeQt.cpp
@@ -43,7 +43,7 @@
#include "HTMLMediaElement.h"
#include "HTMLNames.h"
#if USE(QT_MOBILE_THEME)
-#include "Maemo5Webstyle.h"
+#include "QtMobileWebStyle.h"
#endif
#include "NotImplemented.h"
#include "Page.h"
@@ -152,7 +152,7 @@ RenderThemeQt::RenderThemeQt(Page* page)
#endif
#if USE(QT_MOBILE_THEME)
- m_fallbackStyle = new Maemo5WebStyle;
+ m_fallbackStyle = new QtMobileWebStyle;
#else
m_fallbackStyle = QStyleFactory::create(QLatin1String("windows"));
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list