From dcc8cf2e65d1aa555cce12431a16547e66b469ee Mon Sep 17 00:00:00 2001 From: Steve Block Date: Tue, 27 Apr 2010 16:31:00 +0100 Subject: Merge webkit.org at r58033 : Initial merge by git Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1 --- WebCore/platform/qt/CookieJarQt.cpp | 4 - WebCore/platform/qt/FileSystemQt.cpp | 5 +- WebCore/platform/qt/KURLQt.cpp | 55 +---- WebCore/platform/qt/Localizations.cpp | 11 + WebCore/platform/qt/MIMETypeRegistryQt.cpp | 6 + WebCore/platform/qt/Maemo5Webstyle.cpp | 268 +++++++++++++++++++++ WebCore/platform/qt/Maemo5Webstyle.h | 47 ++++ WebCore/platform/qt/PlatformKeyboardEventQt.cpp | 13 +- WebCore/platform/qt/QWebPageClient.h | 6 +- WebCore/platform/qt/QtAbstractWebPopup.cpp | 22 ++ WebCore/platform/qt/QtAbstractWebPopup.h | 6 + WebCore/platform/qt/QtStyleOptionWebComboBox.h | 59 +++++ WebCore/platform/qt/RenderThemeQt.cpp | 303 +++++++++++++++++++++--- WebCore/platform/qt/RenderThemeQt.h | 33 ++- WebCore/platform/qt/ScrollbarThemeQt.cpp | 4 - WebCore/platform/qt/SharedTimerQt.cpp | 24 +- WebCore/platform/qt/TemporaryLinkStubs.cpp | 2 +- 17 files changed, 758 insertions(+), 110 deletions(-) create mode 100644 WebCore/platform/qt/Maemo5Webstyle.cpp create mode 100644 WebCore/platform/qt/Maemo5Webstyle.h create mode 100644 WebCore/platform/qt/QtStyleOptionWebComboBox.h (limited to 'WebCore/platform/qt') diff --git a/WebCore/platform/qt/CookieJarQt.cpp b/WebCore/platform/qt/CookieJarQt.cpp index 01d1756..15053eb 100644 --- a/WebCore/platform/qt/CookieJarQt.cpp +++ b/WebCore/platform/qt/CookieJarQt.cpp @@ -67,7 +67,6 @@ void setCookies(Document* document, const KURL& url, const String& value) return; QList cookies = QNetworkCookie::parseCookies(QString(value).toAscii()); -#if QT_VERSION >= 0x040500 QList::Iterator it = cookies.begin(); while (it != cookies.end()) { if (it->isHttpOnly()) @@ -75,7 +74,6 @@ void setCookies(Document* document, const KURL& url, const String& value) else ++it; } -#endif jar->setCookiesFromUrl(cookies, u); } @@ -92,10 +90,8 @@ String cookies(const Document* document, const KURL& url) QStringList resultCookies; foreach (QNetworkCookie networkCookie, cookies) { -#if QT_VERSION >= 0x040500 if (networkCookie.isHttpOnly()) continue; -#endif resultCookies.append(QString::fromAscii( networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData())); } diff --git a/WebCore/platform/qt/FileSystemQt.cpp b/WebCore/platform/qt/FileSystemQt.cpp index 4093fad..1da3c68 100644 --- a/WebCore/platform/qt/FileSystemQt.cpp +++ b/WebCore/platform/qt/FileSystemQt.cpp @@ -32,8 +32,8 @@ #include "config.h" #include "FileSystem.h" -#include "CString.h" #include "PlatformString.h" +#include #include #include @@ -154,11 +154,12 @@ bool unloadModule(PlatformModule module) return ::FreeLibrary(module); #else +#ifndef QT_NO_LIBRARY if (module->unload()) { delete module; return true; } - +#endif return false; #endif } diff --git a/WebCore/platform/qt/KURLQt.cpp b/WebCore/platform/qt/KURLQt.cpp index 3bb3db2..ea1a795 100644 --- a/WebCore/platform/qt/KURLQt.cpp +++ b/WebCore/platform/qt/KURLQt.cpp @@ -19,22 +19,14 @@ */ #include "config.h" #include "KURL.h" -#include "CString.h" #include "TextEncoding.h" +#include #include "NotImplemented.h" #include "qurl.h" namespace WebCore { -#if QT_VERSION < 0x040500 -static const char hexnumbers[] = "0123456789ABCDEF"; -static inline char toHex(char c) -{ - return hexnumbers[c & 0xf]; -} -#endif - KURL::KURL(const QUrl& url) { *this = KURL(KURL(), url.toEncoded().constData(), UTF8Encoding()); @@ -42,53 +34,8 @@ KURL::KURL(const QUrl& url) KURL::operator QUrl() const { -#if QT_VERSION < 0x040500 - unsigned length = m_string.length(); - - QByteArray ba; - ba.reserve(length); - - int path = -1; - int host = m_string.find("://"); - if (host != -1) { - host += 3; - - path = m_string.find('/', host); - } - - for (unsigned i = 0; i < length; ++i) { - const char chr = static_cast(m_string[i]); - - switch (chr) { - encode: - case '{': - case '}': - case '|': - case '\\': - case '^': - case '`': - ba.append('%'); - ba.append(toHex((chr & 0xf0) >> 4)); - ba.append(toHex(chr & 0xf)); - break; - case '[': - case ']': - // special case: if this is the host part, don't encode - // otherwise, encode - if (host == -1 || (path != -1 && i >= path)) - goto encode; - // fall through - default: - ba.append(chr); - break; - } - } -#else - // Qt 4.5 or later - // No need for special encoding QString str = QString::fromRawData(reinterpret_cast(m_string.characters()), m_string.length()); QByteArray ba = str.toUtf8(); -#endif QUrl url = QUrl::fromEncoded(ba); return url; diff --git a/WebCore/platform/qt/Localizations.cpp b/WebCore/platform/qt/Localizations.cpp index c919193..8fdd666 100644 --- a/WebCore/platform/qt/Localizations.cpp +++ b/WebCore/platform/qt/Localizations.cpp @@ -350,6 +350,17 @@ String AXMenuListActionVerb() { return String(); } + +String missingPluginText() +{ + return QCoreApplication::translate("QWebPage", "Missing Plug-in", "Label text to be used when a plug-in is missing"); +} + +String crashedPluginText() +{ + notImplemented(); + return String(); +} String multipleFileUploadText(unsigned) { diff --git a/WebCore/platform/qt/MIMETypeRegistryQt.cpp b/WebCore/platform/qt/MIMETypeRegistryQt.cpp index 22cee6f..4161f81 100644 --- a/WebCore/platform/qt/MIMETypeRegistryQt.cpp +++ b/WebCore/platform/qt/MIMETypeRegistryQt.cpp @@ -82,4 +82,10 @@ String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) return "application/octet-stream"; } +bool MIMETypeRegistry::isApplicationPluginMIMEType(const String& mimeType) +{ + return mimeType.startsWith("application/x-qt-plugin", false) + || mimeType.startsWith("application/x-qt-styled-widget", false); +} + } diff --git a/WebCore/platform/qt/Maemo5Webstyle.cpp b/WebCore/platform/qt/Maemo5Webstyle.cpp new file mode 100644 index 0000000..42b0b71 --- /dev/null +++ b/WebCore/platform/qt/Maemo5Webstyle.cpp @@ -0,0 +1,268 @@ +/* + * 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 +#include +#include + +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 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(option); + + if (webCombo) { + multiple = webCombo->multiple(); + cmb = webCombo; + } else + cmb = qstyleoption_cast(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 new file mode 100644 index 0000000..ce717b6 --- /dev/null +++ b/WebCore/platform/qt/Maemo5Webstyle.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 Maemo5Webstyle_h +#define Maemo5Webstyle_h + +#include + +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/PlatformKeyboardEventQt.cpp b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp index 12200f4..56fec70 100644 --- a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp +++ b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp @@ -28,8 +28,8 @@ #include "config.h" #include "PlatformKeyboardEvent.h" -#include "KeyboardCodes.h" #include "NotImplemented.h" +#include "WindowsKeyboardCodes.h" #include @@ -127,6 +127,8 @@ static String keyIdentifierForQtKeyCode(int keyCode) // Standard says that DEL becomes U+007F. case Qt::Key_Delete: return "U+007F"; + case Qt::Key_Backspace: + return "U+0008"; case Qt::Key_Tab: return "U+0009"; case Qt::Key_Backtab: @@ -549,6 +551,15 @@ bool PlatformKeyboardEvent::currentCapsLockState() return false; } +void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey) +{ + notImplemented(); + shiftKey = false; + ctrlKey = false; + altKey = false; + metaKey = false; +} + } // vim: ts=4 sw=4 et diff --git a/WebCore/platform/qt/QWebPageClient.h b/WebCore/platform/qt/QWebPageClient.h index 6d47c29..467941f 100644 --- a/WebCore/platform/qt/QWebPageClient.h +++ b/WebCore/platform/qt/QWebPageClient.h @@ -40,7 +40,9 @@ QT_END_NAMESPACE class QWebPageClient { public: virtual ~QWebPageClient() { } - + + virtual bool isQWidgetClient() const { return false; } + virtual void scroll(int dx, int dy, const QRect&) = 0; virtual void update(const QRect&) = 0; virtual void setInputMethodEnabled(bool enable) = 0; @@ -53,6 +55,7 @@ public: // if scheduleSync is true, we schedule a sync ourselves. otherwise, // we wait for the next update and sync the layers then. virtual void markForSync(bool scheduleSync = false) {} + virtual bool allowsAcceleratedCompositing() const { return false; } #endif #if QT_VERSION >= 0x040600 @@ -80,6 +83,7 @@ public: virtual QPalette palette() const = 0; virtual int screenNumber() const = 0; virtual QWidget* ownerWidget() const = 0; + virtual QRect geometryRelativeToOwnerWidget() const = 0; virtual QObject* pluginParent() const = 0; diff --git a/WebCore/platform/qt/QtAbstractWebPopup.cpp b/WebCore/platform/qt/QtAbstractWebPopup.cpp index f64287d..31ab28d 100644 --- a/WebCore/platform/qt/QtAbstractWebPopup.cpp +++ b/WebCore/platform/qt/QtAbstractWebPopup.cpp @@ -48,6 +48,28 @@ void QtAbstractWebPopup::valueChanged(int index) m_popupClient->valueChanged(index); } +void QtAbstractWebPopup::selectItem(int index, bool allowMultiplySelections, bool shift) +{ +#if ENABLE(NO_LISTBOX_RENDERING) + ListPopupMenuClient* client = static_cast(m_popupClient); + if (client) { + client->listBoxSelectItem(index, allowMultiplySelections, shift); + return; + } +#endif + valueChanged(index); +} + +bool QtAbstractWebPopup::multiple() +{ +#if ENABLE(NO_LISTBOX_RENDERING) + ListPopupMenuClient* client = static_cast(m_popupClient); + return client && client->multiple(); +#else + return false; +#endif +} + QtAbstractWebPopup::ItemType QtAbstractWebPopup::itemType(int idx) const { if (m_popupClient->itemIsSeparator(idx)) diff --git a/WebCore/platform/qt/QtAbstractWebPopup.h b/WebCore/platform/qt/QtAbstractWebPopup.h index 93b4122..dad4997 100644 --- a/WebCore/platform/qt/QtAbstractWebPopup.h +++ b/WebCore/platform/qt/QtAbstractWebPopup.h @@ -40,6 +40,8 @@ public: QString itemToolTip(int idx) const { return m_popupClient->itemToolTip(idx); } bool itemIsEnabled(int idx) const { return m_popupClient->itemIsEnabled(idx); } int itemCount() const { return m_popupClient->listSize(); } + bool itemIsSelected(int idx) const { return m_popupClient->itemIsSelected(idx); } + QWebPageClient* pageClient() const { return m_pageClient; } QRect geometry() const { return m_geometry; } @@ -54,6 +56,10 @@ public: void popupDidHide(); void valueChanged(int index); + void selectItem(int index, bool allowMultiplySelections, bool shift); + bool multiple(); + + QFont font() { return m_popupClient->menuStyle().font().font(); } private: diff --git a/WebCore/platform/qt/QtStyleOptionWebComboBox.h b/WebCore/platform/qt/QtStyleOptionWebComboBox.h new file mode 100644 index 0000000..29c8220 --- /dev/null +++ b/WebCore/platform/qt/QtStyleOptionWebComboBox.h @@ -0,0 +1,59 @@ +/* + * 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 QtStyleOptionWebComboBox_h +#define QtStyleOptionWebComboBox_h + +#include "HTMLSelectElement.h" +#include "RenderObject.h" + +#include + +namespace WebCore { + +class RenderObject; + +class QtStyleOptionWebComboBox : public QStyleOptionComboBox { +public: + QtStyleOptionWebComboBox(RenderObject* o) + : QStyleOptionComboBox() + #if ENABLE(NO_LISTBOX_RENDERING) + , m_multiple(checkMultiple(o)) + #else + , m_multiple(false) + #endif + { + } + + bool multiple() const { return m_multiple; } + +private: + bool m_multiple; + + bool checkMultiple(RenderObject* o) + { + HTMLSelectElement* select = o ? static_cast(o->node()) : 0; + return select ? select->multiple() : false; + } +}; + +} + +#endif // QtStyleOptionWebComboBox_h diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp index 271c11a..9cc32ad 100644 --- a/WebCore/platform/qt/RenderThemeQt.cpp +++ b/WebCore/platform/qt/RenderThemeQt.cpp @@ -39,18 +39,28 @@ #include "Font.h" #include "FontSelector.h" #include "GraphicsContext.h" +#include "HTMLInputElement.h" #include "HTMLMediaElement.h" #include "HTMLNames.h" +#ifdef Q_WS_MAEMO_5 +#include "Maemo5Webstyle.h" +#endif #include "NotImplemented.h" #include "Page.h" +#include "QtStyleOptionWebComboBox.h" #include "QWebPageClient.h" #include "RenderBox.h" +#if ENABLE(PROGRESS_TAG) +#include "RenderProgress.h" +#endif #include "RenderSlider.h" #include "RenderTheme.h" +#include "TimeRanges.h" #include "ScrollbarThemeQt.h" #include "UserAgentStyleSheets.h" #include "qwebpage.h" + #include #include #include @@ -61,6 +71,9 @@ #include #include #include +#if ENABLE(PROGRESS_TAG) +#include +#endif #include #include @@ -129,6 +142,7 @@ PassRefPtr RenderTheme::themeForPage(Page* page) RenderThemeQt::RenderThemeQt(Page* page) : RenderTheme() , m_page(page) + , m_lineEdit(0) { QPushButton button; button.setAttribute(Qt::WA_MacSmallSize); @@ -139,14 +153,43 @@ RenderThemeQt::RenderThemeQt(Page* page) m_buttonFontPixelSize = fontInfo.pixelSize(); #endif +#ifdef Q_WS_MAEMO_5 + m_fallbackStyle = new Maemo5WebStyle; +#else m_fallbackStyle = QStyleFactory::create(QLatin1String("windows")); +#endif } RenderThemeQt::~RenderThemeQt() { delete m_fallbackStyle; + delete m_lineEdit; } +#ifdef Q_WS_MAEMO_5 +bool RenderThemeQt::isControlStyled(const RenderStyle* style, const BorderData& border, const FillLayer& fill, const Color& backgroundColor) const +{ + switch (style->appearance()) { + case PushButtonPart: + case ButtonPart: + case MenulistPart: + case TextFieldPart: + case TextAreaPart: + return true; + case CheckboxPart: + case RadioPart: + return false; + default: + return RenderTheme::isControlStyled(style, border, fill, backgroundColor); + } +} + +int RenderThemeQt::popupInternalPaddingBottom(RenderStyle* style) const +{ + return 1; +} +#endif + // for some widget painting, we need to fallback to Windows style QStyle* RenderThemeQt::fallbackStyle() const { @@ -169,6 +212,18 @@ QStyle* RenderThemeQt::qStyle() const return QApplication::style(); } +String RenderThemeQt::extraDefaultStyleSheet() +{ + String result = RenderTheme::extraDefaultStyleSheet(); +#if ENABLE(NO_LISTBOX_RENDERING) + result += String(themeQtNoListboxesUserAgentStyleSheet, sizeof(themeQtNoListboxesUserAgentStyleSheet)); +#endif +#ifdef Q_WS_MAEMO_5 + result += String(themeQtMaemo5UserAgentStyleSheet, sizeof(themeQtMaemo5UserAgentStyleSheet)); +#endif + return result; +} + bool RenderThemeQt::supportsHover(const RenderStyle*) const { return true; @@ -207,11 +262,13 @@ bool RenderThemeQt::supportsControlTints() const return true; } -static int findFrameLineWidth(QStyle* style) +int RenderThemeQt::findFrameLineWidth(QStyle* style) const { - QLineEdit lineEdit; + if (!m_lineEdit) + m_lineEdit = new QLineEdit(); + QStyleOptionFrameV2 opt; - return style->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, &lineEdit); + return style->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, m_lineEdit); } static QRect inflateButtonRect(const QRect& originalRect, QStyle* style) @@ -289,15 +346,30 @@ int RenderThemeQt::minimumMenuListSize(RenderStyle*) const void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const { - // If the width and height are both specified, then we have nothing to do. - if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto()) - return; - QSize size(0, 0); const QFontMetrics fm(renderStyle->font().font()); QStyle* style = qStyle(); switch (renderStyle->appearance()) { + case TextAreaPart: + case TextFieldPart: { + int padding = findFrameLineWidth(style); + + renderStyle->setPaddingLeft(Length(padding, Fixed)); + renderStyle->setPaddingRight(Length(padding, Fixed)); + renderStyle->setPaddingTop(Length(padding, Fixed)); + renderStyle->setPaddingBottom(Length(padding, Fixed)); + break; + } + default: + break; + } + + // If the width and height are both specified, then we have nothing to do. + if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto()) + return; + + switch (renderStyle->appearance()) { case CheckboxPart: { QStyleOption styleOption; styleOption.state |= QStyle::State_Small; @@ -341,23 +413,6 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const size.setHeight(menuListSize.height()); break; } - case TextFieldPart: { - const int verticalMargin = 1; - const int horizontalMargin = 2; - int h = qMax(fm.lineSpacing(), 14) + 2*verticalMargin; - int w = fm.width(QLatin1Char('x')) * 17 + 2*horizontalMargin; - QStyleOptionFrameV2 opt; - opt.lineWidth = findFrameLineWidth(style); - QSize sz = style->sizeFromContents(QStyle::CT_LineEdit, - &opt, - QSize(w, h).expandedTo(QApplication::globalStrut()), - 0); - size.setHeight(sz.height()); - - renderStyle->setPaddingLeft(Length(opt.lineWidth, Fixed)); - renderStyle->setPaddingRight(Length(opt.lineWidth, Fixed)); - break; - } default: break; } @@ -576,7 +631,7 @@ bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo if (!p.isValid()) return true; - QStyleOptionComboBox opt; + QtStyleOptionWebComboBox opt(o); if (p.widget) opt.initFrom(p.widget); initializeCommonQStyleOptions(opt, o); @@ -593,9 +648,11 @@ bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo void RenderThemeQt::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { +#ifndef Q_WS_MAEMO_5 // WORKAROUND because html.css specifies -webkit-border-radius for