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/RenderThemeQt.cpp | 303 +++++++++++++++++++++++++++++----- 1 file changed, 266 insertions(+), 37 deletions(-) (limited to 'WebCore/platform/qt/RenderThemeQt.cpp') 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