Unreviewed, rolling out r130495.
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2012 12:36:36 +0000 (12:36 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2012 12:36:36 +0000 (12:36 +0000)
http://trac.webkit.org/changeset/130495
https://bugs.webkit.org/show_bug.cgi?id=98268

Source/WebCore:

Made WK2 tests crash.

* Target.pri:
* platform/qt/QStyleFacade.cpp: Removed.
* platform/qt/QStyleFacade.h: Removed.

Source/WebKit:

Made WK2 tests crash....

* WebKit1.pro:

Source/WebKit/qt:

Made WK2 tests crash.

* WebCoreSupport/InitWebCoreQt.cpp:
(WebCore::initializeWebCoreQt):
* WebCoreSupport/QStyleFacadeImp.cpp: Removed.
* WebCoreSupport/QStyleFacadeImp.h: Removed.
* WebCoreSupport/RenderThemeQStyle.cpp: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.cpp.
(WebCore):
(WebCore::initStyleOption):
(WebCore::RenderThemeQStyle::getStylePainter):
(WebCore::StylePainterQStyle::StylePainterQStyle):
(WebCore::StylePainterQStyle::init):
(WebCore::RenderThemeQStyle::create):
(WebCore::RenderThemeQStyle::RenderThemeQStyle):
(WebCore::RenderThemeQStyle::~RenderThemeQStyle):
(WebCore::RenderThemeQStyle::fallbackStyle):
(WebCore::RenderThemeQStyle::setPaletteFromPageClientIfExists):
(WebCore::RenderThemeQStyle::qStyle):
(WebCore::RenderThemeQStyle::findFrameLineWidth):
(WebCore::RenderThemeQStyle::inflateButtonRect):
(WebCore::RenderThemeQStyle::computeSizeBasedOnStyle):
(WebCore::RenderThemeQStyle::adjustButtonStyle):
(WebCore::RenderThemeQStyle::setButtonPadding):
(WebCore::RenderThemeQStyle::paintButton):
(WebCore::RenderThemeQStyle::paintTextField):
(WebCore::RenderThemeQStyle::adjustTextAreaStyle):
(WebCore::RenderThemeQStyle::paintTextArea):
(WebCore::RenderThemeQStyle::setPopupPadding):
(WebCore::RenderThemeQStyle::colorPalette):
(WebCore::RenderThemeQStyle::paintMenuList):
(WebCore::RenderThemeQStyle::adjustMenuListButtonStyle):
(WebCore::RenderThemeQStyle::paintMenuListButton):
(WebCore::RenderThemeQStyle::animationDurationForProgressBar):
(WebCore::RenderThemeQStyle::paintProgressBar):
(WebCore::RenderThemeQStyle::paintSliderTrack):
(WebCore::RenderThemeQStyle::adjustSliderTrackStyle):
(WebCore::RenderThemeQStyle::paintSliderThumb):
(WebCore::RenderThemeQStyle::adjustSliderThumbStyle):
(WebCore::RenderThemeQStyle::paintSearchField):
(WebCore::RenderThemeQStyle::adjustSearchFieldDecorationStyle):
(WebCore::RenderThemeQStyle::paintSearchFieldDecoration):
(WebCore::RenderThemeQStyle::adjustSearchFieldResultsDecorationStyle):
(WebCore::RenderThemeQStyle::paintSearchFieldResultsDecoration):
(WebCore::RenderThemeQStyle::paintInnerSpinButton):
(WebCore::RenderThemeQStyle::initializeCommonQStyleOptions):
(WebCore::RenderThemeQStyle::adjustSliderThumbSize):
* WebCoreSupport/RenderThemeQStyle.h: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.h.
(WebCore):
(RenderThemeQStyle):
(StylePainterQStyle):
(WebCore::StylePainterQStyle::isValid):
(WebCore::StylePainterQStyle::drawPrimitive):
(WebCore::StylePainterQStyle::drawControl):
(WebCore::StylePainterQStyle::drawComplexControl):
* WebCoreSupport/ScrollbarThemeQStyle.cpp: Renamed from Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp.
(WebCore):
(WebCore::ScrollbarThemeQStyle::~ScrollbarThemeQStyle):
(WebCore::scPart):
(WebCore::scrollbarPart):
(WebCore::styleOptionSlider):
(WebCore::ScrollbarThemeQStyle::paint):
(WebCore::ScrollbarThemeQStyle::hitTest):
(WebCore::ScrollbarThemeQStyle::shouldCenterOnThumb):
(WebCore::ScrollbarThemeQStyle::invalidatePart):
(WebCore::ScrollbarThemeQStyle::scrollbarThickness):
(WebCore::ScrollbarThemeQStyle::thumbPosition):
(WebCore::ScrollbarThemeQStyle::thumbLength):
(WebCore::ScrollbarThemeQStyle::trackPosition):
(WebCore::ScrollbarThemeQStyle::trackLength):
(WebCore::ScrollbarThemeQStyle::paintScrollCorner):
(WebCore::ScrollbarThemeQStyle::style):
* WebCoreSupport/ScrollbarThemeQStyle.h: Renamed from Source/WebCore/platform/qt/ScrollbarThemeQStyle.h.
(WebCore):
(ScrollbarThemeQStyle):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130496 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Target.pri
Source/WebCore/platform/qt/QStyleFacade.cpp [deleted file]
Source/WebCore/platform/qt/QStyleFacade.h [deleted file]
Source/WebKit/ChangeLog
Source/WebKit/WebKit1.pro
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp
Source/WebKit/qt/WebCoreSupport/QStyleFacadeImp.cpp [deleted file]
Source/WebKit/qt/WebCoreSupport/QStyleFacadeImp.h [deleted file]
Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp [moved from Source/WebCore/platform/qt/RenderThemeQStyle.cpp with 52% similarity]
Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h [moved from Source/WebCore/platform/qt/RenderThemeQStyle.h with 70% similarity]
Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.cpp [moved from Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp with 55% similarity]
Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.h [moved from Source/WebCore/platform/qt/ScrollbarThemeQStyle.h with 94% similarity]

index a48aae6..aae0462 100644 (file)
@@ -1,5 +1,17 @@
 2012-10-05  Simon Hausmann  <simon.hausmann@digia.com>
 
+        Unreviewed, rolling out r130495.
+        http://trac.webkit.org/changeset/130495
+        https://bugs.webkit.org/show_bug.cgi?id=98268
+
+        Made WK2 tests crash.
+
+        * Target.pri:
+        * platform/qt/QStyleFacade.cpp: Removed.
+        * platform/qt/QStyleFacade.h: Removed.
+
+2012-10-05  Simon Hausmann  <simon.hausmann@digia.com>
+
         [Qt] Make RenderThemeQStyle/ScrollbarThemeQStyle compile without QStyle/QtWidgets
         https://bugs.webkit.org/show_bug.cgi?id=98268
 
index 3034821..078b69a 100644 (file)
@@ -2236,11 +2236,8 @@ HEADERS += \
     platform/qt/ClipboardQt.h \
     platform/qt/CookieJarQt.h \
     platform/qt/QWebPageClient.h \
-    platform/qt/QStyleFacade.h \
-    platform/qt/RenderThemeQStyle.h \
     platform/qt/RenderThemeQt.h \
     platform/qt/RenderThemeQtMobile.h \
-    platform/qt/ScrollbarThemeQStyle.h \
     platform/qt/UserAgentQt.h \
     platform/ScrollableArea.h \
     platform/ScrollAnimator.h \
@@ -2812,11 +2809,8 @@ SOURCES += \
     platform/qt/PasteboardQt.cpp \
     platform/qt/PlatformKeyboardEventQt.cpp \
     platform/qt/PlatformScreenQt.cpp \
-    platform/qt/QStyleFacade.cpp \
-    platform/qt/RenderThemeQStyle.cpp \
     platform/qt/RenderThemeQt.cpp \
     platform/qt/RenderThemeQtMobile.cpp \
-    platform/qt/ScrollbarThemeQStyle.cpp \
     platform/qt/ScrollbarThemeQt.cpp \
     platform/qt/ScrollViewQt.cpp \
     platform/qt/SharedTimerQt.cpp \
diff --git a/Source/WebCore/platform/qt/QStyleFacade.cpp b/Source/WebCore/platform/qt/QStyleFacade.cpp
deleted file mode 100644 (file)
index 4707a2f..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This file is part of the theme implementation for form controls in WebCore.
- *
- * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- * Copyright (C) 2011-2012 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 "QStyleFacade.h"
-
-#include "QWebPageClient.h"
-#include <Chrome.h>
-#include <ChromeClient.h>
-#include <Page.h>
-
-namespace WebCore {
-
-QStyle* QStyleFacade::styleForPage(Page* page)
-{
-    if (!page)
-        return 0;
-    QWebPageClient* pageClient = page->chrome()->client()->platformPageClient();
-
-    if (!pageClient)
-        return 0;
-
-    return pageClient->style();
-}
-
-}
diff --git a/Source/WebCore/platform/qt/QStyleFacade.h b/Source/WebCore/platform/qt/QStyleFacade.h
deleted file mode 100644 (file)
index 4c3e3fd..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * This file is part of the theme implementation for form controls in WebCore.
- *
- * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- * Copyright (C) 2011-2012 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 QStyleFacade_h
-#define QStyleFacade_h
-
-#include <QPalette>
-#include <QRect>
-
-QT_BEGIN_NAMESPACE
-class QStyle;
-QT_END_NAMESPACE
-
-namespace WebCore {
-
-class Page;
-class QStyleFacadeOption;
-
-class QStyleFacade {
-public:
-    enum ButtonSubElement {
-        PushButtonLayoutItem,
-        PushButtonContents
-    };
-
-#define FOR_EACH_MAPPED_STATE(F, SEPARATOR) \
-    F(State_None, 0x00000000) SEPARATOR \
-    F(State_Enabled, 0x00000001) SEPARATOR \
-    F(State_Raised, 0x00000002) SEPARATOR \
-    F(State_Sunken, 0x00000004) SEPARATOR \
-    F(State_Off, 0x00000008) SEPARATOR \
-    F(State_NoChange, 0x00000010) SEPARATOR \
-    F(State_On, 0x00000020) SEPARATOR \
-    F(State_DownArrow, 0x00000040) SEPARATOR \
-    F(State_Horizontal, 0x00000080) SEPARATOR \
-    F(State_HasFocus, 0x00000100) SEPARATOR \
-    F(State_Top, 0x00000200) SEPARATOR \
-    F(State_Bottom, 0x00000400) SEPARATOR \
-    F(State_FocusAtBorder, 0x00000800) SEPARATOR \
-    F(State_AutoRaise, 0x00001000) SEPARATOR \
-    F(State_MouseOver, 0x00002000) SEPARATOR \
-    F(State_UpArrow, 0x00004000) SEPARATOR \
-    F(State_Selected, 0x00008000) SEPARATOR \
-    F(State_Active, 0x00010000) SEPARATOR \
-    F(State_Window, 0x00020000) SEPARATOR \
-    F(State_Open, 0x00040000) SEPARATOR \
-    F(State_Children, 0x00080000) SEPARATOR \
-    F(State_Item, 0x00100000) SEPARATOR \
-    F(State_Sibling, 0x00200000) SEPARATOR \
-    F(State_Editing, 0x00400000) SEPARATOR \
-    F(State_KeyboardFocusChange, 0x00800000) SEPARATOR \
-    F(State_ReadOnly, 0x02000000) SEPARATOR \
-    F(State_Small, 0x04000000) SEPARATOR \
-    F(State_Mini, 0x0800000)
-
-#define COMMA ,
-#define SEMICOLON ;
-#define DEFINE_MAPPED_STATE(Name, Value) \
-    Name = Value
-
-    // ### Remove unused states.
-    enum StateFlag {
-        FOR_EACH_MAPPED_STATE(DEFINE_MAPPED_STATE, COMMA)
-    };
-    Q_DECLARE_FLAGS(State, StateFlag)
-
-#define FOR_EACH_MAPPED_METRIC(F, SEPARATOR) \
-    F(PM_ButtonMargin) SEPARATOR \
-    F(PM_DefaultFrameWidth) SEPARATOR \
-    F(PM_IndicatorWidth) SEPARATOR \
-    F(PM_ExclusiveIndicatorWidth) SEPARATOR \
-    F(PM_ButtonIconSize)
-
-#define DEFINE_METRIC(F) F
-
-    enum PixelMetric {
-        FOR_EACH_MAPPED_METRIC(DEFINE_METRIC, COMMA)
-    };
-
-    enum ContentsType {
-        CT_ComboBox,
-        CT_PushButton
-    };
-
-#define FOR_EACH_SUBCONTROL(F, SEPARATOR) \
-    F(SC_None, 0x00000000) SEPARATOR \
-    F(SC_ScrollBarAddLine, 0x00000001) SEPARATOR \
-    F(SC_ScrollBarSubLine, 0x00000002) SEPARATOR \
-    F(SC_ScrollBarAddPage, 0x00000004) SEPARATOR \
-    F(SC_ScrollBarSubPage, 0x00000008) SEPARATOR \
-    F(SC_ScrollBarFirst, 0x00000010) SEPARATOR \
-    F(SC_ScrollBarLast, 0x00000020) SEPARATOR \
-    F(SC_ScrollBarSlider, 0x00000040) SEPARATOR \
-    F(SC_ScrollBarGroove, 0x00000080)
-
-#define DEFINE_SUBCONTROL(F, Value) F
-
-    enum SubControl {
-        FOR_EACH_SUBCONTROL(DEFINE_SUBCONTROL, COMMA)
-    };
-
-    virtual ~QStyleFacade() { }
-
-    virtual QRect buttonSubElementRect(ButtonSubElement buttonElement, State, const QRect& originalRect) const = 0;
-
-    virtual int findFrameLineWidth() const = 0;
-    virtual int simplePixelMetric(PixelMetric, State = State_None) const = 0;
-    virtual int buttonMargin(State, const QRect& originalRect) const = 0;
-    virtual int sliderLength(Qt::Orientation) const = 0;
-    virtual int sliderThickness(Qt::Orientation) const = 0;
-    virtual int progressBarChunkWidth(const QSize&) const = 0;
-    virtual void getButtonMetrics(QString* buttonFontFamily, int* buttonFontPixelSize) const = 0;
-
-    virtual QSize sizeFromContents(ContentsType, State, const QSize& contentsSize) const = 0;
-
-    enum ButtonType {
-        PushButton,
-        RadioButton,
-        CheckBox
-    };
-
-    virtual void paintButton(QPainter*, ButtonType, const QStyleFacadeOption&) = 0;
-    virtual void paintTextField(QPainter*, const QStyleFacadeOption&) = 0;
-    virtual void paintComboBox(QPainter*, const QStyleFacadeOption&) = 0;
-    virtual void paintComboBoxArrow(QPainter*, const QStyleFacadeOption&) = 0;
-
-    virtual void paintSliderTrack(QPainter*, const QStyleFacadeOption&) = 0;
-    virtual void paintSliderThumb(QPainter*, const QStyleFacadeOption&) = 0;
-    virtual void paintInnerSpinButton(QPainter*, const QStyleFacadeOption&, bool spinBoxUp) = 0;
-    virtual void paintProgressBar(QPainter*, const QStyleFacadeOption&, double progress, double animationProgress) = 0;
-
-    virtual int scrollBarExtent(bool mini) = 0;
-    virtual bool scrollBarMiddleClickAbsolutePositionStyleHint() const = 0;
-    virtual void paintScrollCorner(QPainter*, const QRect&) = 0;
-
-    virtual SubControl hitTestScrollBar(const QStyleFacadeOption&, const QPoint& pos) = 0;
-    virtual QRect scrollBarSubControlRect(const QStyleFacadeOption&, SubControl) = 0;
-    virtual void paintScrollBar(QPainter*, const QStyleFacadeOption&) = 0;
-
-    virtual QObject* widgetForPainter(QPainter*) = 0;
-
-    virtual bool isValid() const = 0;
-
-    static QStyle* styleForPage(Page*);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleFacade::State)
-
-struct QStyleFacadeOption {
-    QStyleFacadeOption()
-        : state(QStyleFacade::State_None)
-        , direction(Qt::LayoutDirectionAuto)
-    {
-        slider.orientation = Qt::Horizontal;
-        slider.upsideDown = false;
-        slider.minimum = 0;
-        slider.maximum = 0;
-        slider.position = 0;
-        slider.value = 0;
-        slider.singleStep = 0;
-        slider.pageStep = 0;
-        slider.activeSubControls = QStyleFacade::SC_None;
-    }
-
-    QStyleFacade::State state;
-    QRect rect;
-    Qt::LayoutDirection direction;
-    QPalette palette;
-
-    // Slider features
-    struct {
-        Qt::Orientation orientation;
-        bool upsideDown;
-        int minimum;
-        int maximum;
-        int position;
-        int value;
-        int singleStep;
-        int pageStep;
-        QStyleFacade::SubControl activeSubControls;
-    } slider;
-};
-
-}
-
-#endif // QStyleFacade_h
index ca88544..2802ede 100644 (file)
@@ -1,5 +1,15 @@
 2012-10-05  Simon Hausmann  <simon.hausmann@digia.com>
 
+        Unreviewed, rolling out r130495.
+        http://trac.webkit.org/changeset/130495
+        https://bugs.webkit.org/show_bug.cgi?id=98268
+
+        Made WK2 tests crash....
+
+        * WebKit1.pro:
+
+2012-10-05  Simon Hausmann  <simon.hausmann@digia.com>
+
         [Qt] Make RenderThemeQStyle/ScrollbarThemeQStyle compile without QStyle/QtWidgets
         https://bugs.webkit.org/show_bug.cgi?id=98268
 
index 75d4d79..ae23c4e 100644 (file)
@@ -48,8 +48,9 @@ SOURCES += \
     $$PWD/qt/WebCoreSupport/NotificationPresenterClientQt.cpp \
     $$PWD/qt/WebCoreSupport/PageClientQt.cpp \
     $$PWD/qt/WebCoreSupport/PopupMenuQt.cpp \
-    $$PWD/qt/WebCoreSupport/QStyleFacadeImp.cpp \
     $$PWD/qt/WebCoreSupport/QtPlatformPlugin.cpp \
+    $$PWD/qt/WebCoreSupport/RenderThemeQStyle.cpp \
+    $$PWD/qt/WebCoreSupport/ScrollbarThemeQStyle.cpp \
     $$PWD/qt/WebCoreSupport/SearchPopupMenuQt.cpp \
     $$PWD/qt/WebCoreSupport/TextCheckerClientQt.cpp \
     $$PWD/qt/WebCoreSupport/PlatformStrategiesQt.cpp \
@@ -85,8 +86,9 @@ HEADERS += \
     $$PWD/qt/WebCoreSupport/NotificationPresenterClientQt.h \
     $$PWD/qt/WebCoreSupport/PageClientQt.h \
     $$PWD/qt/WebCoreSupport/PopupMenuQt.h \
-    $$PWD/qt/WebCoreSupport/QStyleFacadeImp.h \
     $$PWD/qt/WebCoreSupport/QtPlatformPlugin.h \
+    $$PWD/qt/WebCoreSupport/RenderThemeQStyle.h \
+    $$PWD/qt/WebCoreSupport/ScrollbarThemeQStyle.h \
     $$PWD/qt/WebCoreSupport/SearchPopupMenuQt.h \
     $$PWD/qt/WebCoreSupport/TextCheckerClientQt.h \
     $$PWD/qt/WebCoreSupport/PlatformStrategiesQt.h \
index 0349c6c..65ae264 100644 (file)
@@ -1,5 +1,86 @@
 2012-10-05  Simon Hausmann  <simon.hausmann@digia.com>
 
+        Unreviewed, rolling out r130495.
+        http://trac.webkit.org/changeset/130495
+        https://bugs.webkit.org/show_bug.cgi?id=98268
+
+        Made WK2 tests crash.
+
+        * WebCoreSupport/InitWebCoreQt.cpp:
+        (WebCore::initializeWebCoreQt):
+        * WebCoreSupport/QStyleFacadeImp.cpp: Removed.
+        * WebCoreSupport/QStyleFacadeImp.h: Removed.
+        * WebCoreSupport/RenderThemeQStyle.cpp: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.cpp.
+        (WebCore):
+        (WebCore::initStyleOption):
+        (WebCore::RenderThemeQStyle::getStylePainter):
+        (WebCore::StylePainterQStyle::StylePainterQStyle):
+        (WebCore::StylePainterQStyle::init):
+        (WebCore::RenderThemeQStyle::create):
+        (WebCore::RenderThemeQStyle::RenderThemeQStyle):
+        (WebCore::RenderThemeQStyle::~RenderThemeQStyle):
+        (WebCore::RenderThemeQStyle::fallbackStyle):
+        (WebCore::RenderThemeQStyle::setPaletteFromPageClientIfExists):
+        (WebCore::RenderThemeQStyle::qStyle):
+        (WebCore::RenderThemeQStyle::findFrameLineWidth):
+        (WebCore::RenderThemeQStyle::inflateButtonRect):
+        (WebCore::RenderThemeQStyle::computeSizeBasedOnStyle):
+        (WebCore::RenderThemeQStyle::adjustButtonStyle):
+        (WebCore::RenderThemeQStyle::setButtonPadding):
+        (WebCore::RenderThemeQStyle::paintButton):
+        (WebCore::RenderThemeQStyle::paintTextField):
+        (WebCore::RenderThemeQStyle::adjustTextAreaStyle):
+        (WebCore::RenderThemeQStyle::paintTextArea):
+        (WebCore::RenderThemeQStyle::setPopupPadding):
+        (WebCore::RenderThemeQStyle::colorPalette):
+        (WebCore::RenderThemeQStyle::paintMenuList):
+        (WebCore::RenderThemeQStyle::adjustMenuListButtonStyle):
+        (WebCore::RenderThemeQStyle::paintMenuListButton):
+        (WebCore::RenderThemeQStyle::animationDurationForProgressBar):
+        (WebCore::RenderThemeQStyle::paintProgressBar):
+        (WebCore::RenderThemeQStyle::paintSliderTrack):
+        (WebCore::RenderThemeQStyle::adjustSliderTrackStyle):
+        (WebCore::RenderThemeQStyle::paintSliderThumb):
+        (WebCore::RenderThemeQStyle::adjustSliderThumbStyle):
+        (WebCore::RenderThemeQStyle::paintSearchField):
+        (WebCore::RenderThemeQStyle::adjustSearchFieldDecorationStyle):
+        (WebCore::RenderThemeQStyle::paintSearchFieldDecoration):
+        (WebCore::RenderThemeQStyle::adjustSearchFieldResultsDecorationStyle):
+        (WebCore::RenderThemeQStyle::paintSearchFieldResultsDecoration):
+        (WebCore::RenderThemeQStyle::paintInnerSpinButton):
+        (WebCore::RenderThemeQStyle::initializeCommonQStyleOptions):
+        (WebCore::RenderThemeQStyle::adjustSliderThumbSize):
+        * WebCoreSupport/RenderThemeQStyle.h: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.h.
+        (WebCore):
+        (RenderThemeQStyle):
+        (StylePainterQStyle):
+        (WebCore::StylePainterQStyle::isValid):
+        (WebCore::StylePainterQStyle::drawPrimitive):
+        (WebCore::StylePainterQStyle::drawControl):
+        (WebCore::StylePainterQStyle::drawComplexControl):
+        * WebCoreSupport/ScrollbarThemeQStyle.cpp: Renamed from Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp.
+        (WebCore):
+        (WebCore::ScrollbarThemeQStyle::~ScrollbarThemeQStyle):
+        (WebCore::scPart):
+        (WebCore::scrollbarPart):
+        (WebCore::styleOptionSlider):
+        (WebCore::ScrollbarThemeQStyle::paint):
+        (WebCore::ScrollbarThemeQStyle::hitTest):
+        (WebCore::ScrollbarThemeQStyle::shouldCenterOnThumb):
+        (WebCore::ScrollbarThemeQStyle::invalidatePart):
+        (WebCore::ScrollbarThemeQStyle::scrollbarThickness):
+        (WebCore::ScrollbarThemeQStyle::thumbPosition):
+        (WebCore::ScrollbarThemeQStyle::thumbLength):
+        (WebCore::ScrollbarThemeQStyle::trackPosition):
+        (WebCore::ScrollbarThemeQStyle::trackLength):
+        (WebCore::ScrollbarThemeQStyle::paintScrollCorner):
+        (WebCore::ScrollbarThemeQStyle::style):
+        * WebCoreSupport/ScrollbarThemeQStyle.h: Renamed from Source/WebCore/platform/qt/ScrollbarThemeQStyle.h.
+        (WebCore):
+        (ScrollbarThemeQStyle):
+
+2012-10-05  Simon Hausmann  <simon.hausmann@digia.com>
+
         [Qt] Make RenderThemeQStyle/ScrollbarThemeQStyle compile without QStyle/QtWidgets
         https://bugs.webkit.org/show_bug.cgi?id=98268
 
index 2374bb5..c63ccb0 100644 (file)
@@ -33,7 +33,6 @@
 #include "Image.h"
 #include "NotImplemented.h"
 #include "PlatformStrategiesQt.h"
-#include "QStyleFacadeImp.h"
 #include "RenderThemeQStyle.h"
 #include "ScriptController.h"
 #include "ScrollbarThemeQStyle.h"
@@ -77,7 +76,6 @@ void initializeWebCoreQt()
     PlatformStrategiesQt::initialize();
     QtWebElementRuntime::initialize();
 
-    RenderThemeQStyle::setStyleFactoryFunction(WebKit::QStyleFacadeImp::create);
     RenderThemeQt::setCustomTheme(RenderThemeQStyle::create, new ScrollbarThemeQStyle);
 
 #if USE(QTKIT)
diff --git a/Source/WebKit/qt/WebCoreSupport/QStyleFacadeImp.cpp b/Source/WebKit/qt/WebCoreSupport/QStyleFacadeImp.cpp
deleted file mode 100644 (file)
index 6e84821..0000000
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * This file is part of the theme implementation for form controls in WebCore.
- *
- * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- * Copyright (C) 2011-2012 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 "QStyleFacadeImp.h"
-
-#include <QApplication>
-#include <QLineEdit>
-#include <QMacStyle>
-#include <QPainter>
-#include <QPushButton>
-#ifndef QT_NO_STYLE_PLASTIQUE
-#include <QPlastiqueStyle>
-#endif
-#include <QStyleFactory>
-#include <QStyleOption>
-
-#include <QWebPageClient.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-static QStyle::State convertToQStyleState(QStyleFacade::State state)
-{
-    QStyle::State result;
-#define CONVERT_STATE(ProxiedState, Value) \
-    if (state & QStyleFacade::ProxiedState) \
-        result |= QStyle::ProxiedState;
-
-    FOR_EACH_MAPPED_STATE(CONVERT_STATE, )
-
-#undef CONVERT_STATE
-
-    return result;
-}
-
-static QStyle::SubControl convertToQStyleSubControl(QStyleFacade::SubControl sc)
-{
-#define CONVERT_SUBCONTROL(F, Value) \
-    case QStyleFacade::F: return QStyle::F
-
-    switch (sc) {
-        FOR_EACH_SUBCONTROL(CONVERT_SUBCONTROL, SEMICOLON);
-    }
-    ASSERT_NOT_REACHED();
-    return QStyle::SC_None;
-#undef CONVERT_SUBCONTROL
-}
-
-static void initGenericStyleOption(QStyleOption* option, QWidget* widget, const QStyleFacadeOption& facadeOption)
-{
-    if (widget)
-        option->init(widget);
-    else
-        // If a widget is not directly available for rendering, we fallback to default
-        // value for an active widget.
-        option->state = QStyle::State_Active | QStyle::State_Enabled;
-
-    option->rect = facadeOption.rect;
-    option->state = convertToQStyleState(facadeOption.state);
-    option->direction = facadeOption.direction;
-    option->palette = facadeOption.palette;
-}
-
-static void initSpecificStyleOption(QStyleOption*, const QStyleFacadeOption&)
-{
-}
-
-static void initSpecificStyleOption(QStyleOptionSlider* sliderOption, const QStyleFacadeOption& facadeOption)
-{
-    sliderOption->orientation = facadeOption.slider.orientation;
-    sliderOption->upsideDown = facadeOption.slider.upsideDown;
-    sliderOption->minimum = facadeOption.slider.minimum;
-    sliderOption->maximum = facadeOption.slider.maximum;
-    sliderOption->sliderPosition = facadeOption.slider.position;
-    sliderOption->sliderValue = facadeOption.slider.value;
-    sliderOption->singleStep = facadeOption.slider.singleStep;
-    sliderOption->pageStep = facadeOption.slider.pageStep;
-    sliderOption->activeSubControls = convertToQStyleSubControl(facadeOption.slider.activeSubControls);
-}
-
-template <typename StyleOption>
-class MappedStyleOption : public StyleOption {
-
-public:
-    MappedStyleOption(QWidget* widget, const QStyleFacadeOption& facadeOption)
-    {
-        initGenericStyleOption(this, widget, facadeOption);
-        initSpecificStyleOption(this, facadeOption);
-    }
-};
-
-static QStyle::PixelMetric convertPixelMetric(QStyleFacade::PixelMetric state)
-{
-#define CONVERT_METRIC(Metric) \
-    case QStyleFacade::Metric: return QStyle::Metric
-
-    switch (state) {
-        FOR_EACH_MAPPED_METRIC(CONVERT_METRIC, SEMICOLON);
-    }
-    ASSERT_NOT_REACHED();
-    return QStyle::PM_CustomBase;
-
-#undef CONVERT_METRIC
-}
-
-static QStyleFacade::SubControl convertToQStyleFacadeSubControl(QStyle::SubControl sc)
-{
-#define CONVERT_SUBCONTROL(F, Value) \
-    case QStyle::F: return QStyleFacade::F
-
-    switch (sc) {
-        FOR_EACH_SUBCONTROL(CONVERT_SUBCONTROL, SEMICOLON);
-    }
-    ASSERT_NOT_REACHED();
-    return QStyleFacade::SC_None;
-#undef CONVERT_SUBCONTROL
-}
-
-QStyleFacadeImp::QStyleFacadeImp(Page* page)
-    : m_page(page)
-    , m_style(0)
-{
-    m_fallbackStyle = QStyleFactory::create(QLatin1String("windows"));
-    m_ownFallbackStyle = true;
-    if (!m_fallbackStyle) {
-        m_fallbackStyle = QApplication::style();
-        m_ownFallbackStyle = false;
-    }
-}
-
-QStyleFacadeImp::~QStyleFacadeImp()
-{
-    if (m_ownFallbackStyle)
-        delete m_fallbackStyle;
-}
-
-QRect QStyleFacadeImp::buttonSubElementRect(QStyleFacade::ButtonSubElement buttonElement, State state, const QRect& originalRect) const
-{
-    QStyleOptionButton option;
-    option.state = convertToQStyleState(state);
-    option.rect = originalRect;
-
-    QStyle::SubElement subElement = QStyle::SE_CustomBase;
-    switch (buttonElement) {
-    case PushButtonLayoutItem: subElement = QStyle::SE_PushButtonLayoutItem; break;
-    case PushButtonContents: subElement = QStyle::SE_PushButtonContents; break;
-    default: ASSERT_NOT_REACHED();
-    }
-    return style()->subElementRect(subElement, &option);
-}
-
-int QStyleFacadeImp::findFrameLineWidth() const
-{
-    if (!m_lineEdit)
-        m_lineEdit.reset(new QLineEdit());
-
-    return style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, m_lineEdit.data());
-}
-
-int QStyleFacadeImp::simplePixelMetric(QStyleFacade::PixelMetric metric, State state) const
-{
-    QStyleOption opt;
-    opt.state = convertToQStyleState(state);
-    return style()->pixelMetric(convertPixelMetric(metric), &opt, 0);
-}
-
-int QStyleFacadeImp::buttonMargin(State state, const QRect& originalRect) const
-{
-    QStyleOptionButton styleOption;
-    styleOption.state = convertToQStyleState(state);
-    styleOption.rect = originalRect;
-    return style()->pixelMetric(QStyle::PM_ButtonMargin, &styleOption, 0);
-}
-
-int QStyleFacadeImp::sliderLength(Qt::Orientation orientation) const
-{
-    QStyleOptionSlider opt;
-    opt.orientation = orientation;
-    return style()->pixelMetric(QStyle::PM_SliderLength, &opt);
-}
-
-int QStyleFacadeImp::sliderThickness(Qt::Orientation orientation) const
-{
-    QStyleOptionSlider opt;
-    opt.orientation = orientation;
-    return style()->pixelMetric(QStyle::PM_SliderThickness, &opt);
-}
-
-int QStyleFacadeImp::progressBarChunkWidth(const QSize& size) const
-{
-    QStyleOptionProgressBarV2 option;
-    option.rect.setSize(size);
-    // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed,
-    // we simulate one square animating across the progress bar.
-    return style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option);
-}
-
-void QStyleFacadeImp::getButtonMetrics(QString *buttonFontFamily, int *buttonFontPixelSize) const
-{
-    QPushButton button;
-    QFont defaultButtonFont = QApplication::font(&button);
-    *buttonFontFamily = defaultButtonFont.family();
-    *buttonFontPixelSize = 0;
-#ifdef Q_WS_MAC
-    button.setAttribute(Qt::WA_MacSmallSize);
-    QFontInfo fontInfo(defaultButtonFont);
-    *buttonFontPixelSize = fontInfo.pixelSize();
-#endif
-}
-
-QSize QStyleFacadeImp::sizeFromContents(QStyleFacade::ContentsType type, QStyleFacade::State state, const QSize& contentsSize) const
-{
-    QStyleOption opt;
-    opt.state = convertToQStyleState(state);
-
-    QStyle::ContentsType contentsType = QStyle::CT_CustomBase;
-    switch (type) {
-    case QStyleFacade::CT_ComboBox: contentsType = QStyle::CT_ComboBox; break;
-    case QStyleFacade::CT_PushButton: contentsType = QStyle::CT_PushButton; break;
-    }
-
-    return style()->sizeFromContents(contentsType, &opt, contentsSize);
-}
-
-void QStyleFacadeImp::paintButton(QPainter* painter, QStyleFacade::ButtonType type, const QStyleFacadeOption &proxyOption)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-    MappedStyleOption<QStyleOptionButton> option(widget, proxyOption);
-
-    if (type == PushButton)
-        style()->drawControl(QStyle::CE_PushButton, &option, painter, widget);
-    else if (type == RadioButton)
-        style()->drawControl(QStyle::CE_RadioButton, &option, painter, widget);
-    else if (type == CheckBox)
-        style()->drawControl(QStyle::CE_CheckBox, &option, painter, widget);
-}
-
-void QStyleFacadeImp::paintTextField(QPainter *painter, const QStyleFacadeOption &proxyOption)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionFrameV2> panel(widget, proxyOption);
-
-    panel.lineWidth = findFrameLineWidth();
-    panel.features = QStyleOptionFrameV2::None;
-
-    style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, painter, widget);
-}
-
-void QStyleFacadeImp::paintComboBox(QPainter *painter, const QStyleFacadeOption &proxyOption)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionComboBox> opt(widget, proxyOption);
-
-    IntRect rect = opt.rect;
-
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
-    // QMacStyle makes the combo boxes a little bit smaller to leave space for the focus rect.
-    // Because of it, the combo button is drawn at a point to the left of where it was expect to be and may end up
-    // overlapped with the text. This will force QMacStyle to draw the combo box with the expected width.
-    if (qobject_cast<QMacStyle*>(m_style))
-        rect.inflateX(3);
-#endif
-
-    const QPoint topLeft = rect.location();
-    painter->translate(topLeft);
-    opt.rect.moveTo(QPoint(0, 0));
-    opt.rect.setSize(rect.size());
-
-    style()->drawComplexControl(QStyle::CC_ComboBox, &opt, painter, widget);
-    painter->translate(-topLeft);
-}
-
-void QStyleFacadeImp::paintComboBoxArrow(QPainter *painter, const QStyleFacadeOption &proxyOption)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionComboBox> opt(widget, proxyOption);
-    opt.subControls = QStyle::SC_ComboBoxArrow;
-    // for drawing the combo box arrow, rely only on the fallback style
-    m_fallbackStyle->drawComplexControl(QStyle::CC_ComboBox, &opt, painter, widget);
-}
-
-void QStyleFacadeImp::paintSliderTrack(QPainter* painter, const QStyleFacadeOption& proxyOption)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionSlider> option(widget, proxyOption);
-    option.subControls = QStyle::SC_SliderGroove;
-
-    option.upsideDown = proxyOption.slider.upsideDown;
-    option.minimum = proxyOption.slider.minimum;
-    option.maximum = proxyOption.slider.maximum;
-    option.sliderPosition = proxyOption.slider.position;
-    option.orientation = proxyOption.slider.orientation;
-
-    style()->drawComplexControl(QStyle::CC_Slider, &option, painter, widget);
-
-    if (option.state & QStyle::State_HasFocus) {
-        QStyleOptionFocusRect focusOption;
-        focusOption.rect = option.rect;
-        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusOption, painter, widget);
-    }
-}
-
-void QStyleFacadeImp::paintSliderThumb(QPainter* painter, const QStyleFacadeOption& proxyOption)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionSlider> option(widget, proxyOption);
-
-    option.subControls = QStyle::SC_SliderHandle;
-    if (option.state & QStyle::State_Sunken)
-        option.activeSubControls = QStyle::SC_SliderHandle;
-
-    style()->drawComplexControl(QStyle::CC_Slider, &option, painter, widget);
-}
-
-void QStyleFacadeImp::paintInnerSpinButton(QPainter* painter, const QStyleFacadeOption& proxyOption, bool spinBoxUp)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionSpinBox> option(widget, proxyOption);
-
-    option.subControls = QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown;
-    if (!(option.state & QStyle::State_ReadOnly)) {
-        if (option.state & QStyle::State_Enabled)
-            option.stepEnabled = QAbstractSpinBox::StepUpEnabled | QAbstractSpinBox::StepDownEnabled;
-        if (option.state & QStyle::State_Sunken) {
-            if (spinBoxUp)
-                option.activeSubControls = QStyle::SC_SpinBoxUp;
-            else
-                option.activeSubControls = QStyle::SC_SpinBoxDown;
-        }
-    }
-
-    IntRect buttonRect = option.rect;
-    // Default to moving the buttons a little bit within the editor frame.
-    int inflateX = -2;
-    int inflateY = -2;
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
-    // QMacStyle will position the aqua buttons flush to the right.
-    // This will move them more within the control for better style, a la
-    // Chromium look & feel.
-    if (qobject_cast<QMacStyle*>(m_style)) {
-        inflateX = -4;
-        // Render mini aqua spin buttons for QMacStyle to fit nicely into
-        // the editor area, like Chromium.
-        option.state |= QStyle::State_Mini;
-    }
-#endif
-#if !defined(QT_NO_STYLE_PLASTIQUE)
-    // QPlastiqueStyle looks best when the spin buttons are flush with the frame's edge.
-    if (qobject_cast<QPlastiqueStyle*>(style())) {
-        inflateX = 0;
-        inflateY = 0;
-    }
-#endif
-
-    buttonRect.inflateX(inflateX);
-    buttonRect.inflateY(inflateY);
-    option.rect = buttonRect;
-
-    style()->drawComplexControl(QStyle::CC_SpinBox, &option, painter, widget);
-}
-
-void QStyleFacadeImp::paintProgressBar(QPainter* painter, const QStyleFacadeOption& proxyOption, double progress, double animationProgress)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionProgressBarV2> option(widget, proxyOption);
-
-    option.maximum = std::numeric_limits<int>::max();
-    option.minimum = 0;
-    option.progress = progress * std::numeric_limits<int>::max();
-
-    const QPoint topLeft = option.rect.topLeft();
-    painter->translate(topLeft);
-    option.rect.moveTo(QPoint(0, 0));
-
-    if (progress < 0) {
-        // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed,
-        // we simulate one square animating across the progress bar.
-        style()->drawControl(QStyle::CE_ProgressBarGroove, &option, painter, widget);
-        int chunkWidth = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option);
-        QColor color = (option.palette.highlight() == option.palette.background()) ? option.palette.color(QPalette::Active, QPalette::Highlight) : option.palette.color(QPalette::Highlight);
-        if (option.direction == Qt::RightToLeft)
-            painter->fillRect(option.rect.right() - chunkWidth  - animationProgress * option.rect.width(), 0, chunkWidth, option.rect.height(), color);
-        else
-            painter->fillRect(animationProgress * option.rect.width(), 0, chunkWidth, option.rect.height(), color);
-    } else
-        style()->drawControl(QStyle::CE_ProgressBar, &option, painter, widget);
-
-    painter->translate(-topLeft);
-}
-
-int QStyleFacadeImp::scrollBarExtent(bool mini)
-{
-    QStyleOptionSlider o;
-    o.orientation = Qt::Vertical;
-    o.state &= ~QStyle::State_Horizontal;
-    if (mini)
-        o.state |= QStyle::State_Mini;
-    return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
-}
-
-bool QStyleFacadeImp::scrollBarMiddleClickAbsolutePositionStyleHint() const
-{
-    return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition);
-}
-
-void QStyleFacadeImp::paintScrollCorner(QPainter* painter, const QRect& rect)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    QStyleOption option;
-    option.rect = rect;
-    style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, painter, widget);
-}
-
-QStyleFacade::SubControl QStyleFacadeImp::hitTestScrollBar(const QStyleFacadeOption &proxyOption, const QPoint &pos)
-{
-    MappedStyleOption<QStyleOptionSlider> opt(0, proxyOption);
-    QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, pos, 0);
-    return convertToQStyleFacadeSubControl(sc);
-}
-
-QRect QStyleFacadeImp::scrollBarSubControlRect(const QStyleFacadeOption &proxyOption, QStyleFacade::SubControl subControl)
-{
-    MappedStyleOption<QStyleOptionSlider> opt(0, proxyOption);
-    return style()->subControlRect(QStyle::CC_ScrollBar, &opt, convertToQStyleSubControl(subControl), 0);
-}
-
-void QStyleFacadeImp::paintScrollBar(QPainter *painter, const QStyleFacadeOption &proxyOption)
-{
-    QWidget* widget = qobject_cast<QWidget*>(widgetForPainter(painter));
-
-    MappedStyleOption<QStyleOptionSlider> opt(widget, proxyOption);
-
-#ifdef Q_WS_MAC
-    // FIXME: We also need to check the widget style but today ScrollbarTheme is not aware of the page so we
-    // can't get the widget.
-    if (qobject_cast<QMacStyle*>(m_style))
-        m_style->drawComplexControl(QStyle::CC_ScrollBar, &opt, painter, widget);
-    else
-#endif
-    {
-        // The QStyle expects the background to be already filled.
-        painter->fillRect(opt.rect, opt.palette.background());
-
-        const QPoint topLeft = opt.rect.topLeft();
-        painter->translate(topLeft);
-        opt.rect.moveTo(QPoint(0, 0));
-        style()->drawComplexControl(QStyle::CC_ScrollBar, &opt, painter, widget);
-        opt.rect.moveTo(topLeft);
-    }
-}
-
-QObject* QStyleFacadeImp::widgetForPainter(QPainter* painter)
-{
-    QPaintDevice* dev = 0;
-    if (painter)
-        dev = painter->device();
-    if (dev && dev->devType() == QInternal::Widget)
-        return static_cast<QWidget*>(dev);
-    return 0;
-}
-
-QStyle* QStyleFacadeImp::style() const
-{
-    if (m_style)
-        return m_style;
-
-    m_style = QStyleFacade::styleForPage(m_page);
-
-    if (!m_style)
-        m_style = QApplication::style();
-
-    return m_style;
-}
-
-}
diff --git a/Source/WebKit/qt/WebCoreSupport/QStyleFacadeImp.h b/Source/WebKit/qt/WebCoreSupport/QStyleFacadeImp.h
deleted file mode 100644 (file)
index ca44e08..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * This file is part of the theme implementation for form controls in WebCore.
- *
- * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
- * Copyright (C) 2011-2012 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 QStyleFacadeImp_h
-#define QStyleFacadeImp_h
-
-#include <QStyleFacade.h>
-
-QT_BEGIN_NAMESPACE
-class QStyle;
-class QLineEdit;
-class QStyleOption;
-class QStyleOptionSlider;
-class QPainter;
-class QObject;
-QT_END_NAMESPACE
-
-namespace WebCore {
-class Page;
-}
-
-namespace WebKit {
-
-class QStyleFacadeImp : public WebCore::QStyleFacade {
-public:
-    QStyleFacadeImp(WebCore::Page* = 0);
-    virtual ~QStyleFacadeImp();
-
-    static WebCore::QStyleFacade* create(WebCore::Page* page)
-    { return new QStyleFacadeImp(page); }
-
-    virtual QRect buttonSubElementRect(ButtonSubElement, State, const QRect& originalRect) const;
-
-    virtual int findFrameLineWidth() const;
-    virtual int simplePixelMetric(PixelMetric, State = State_None) const;
-    virtual int buttonMargin(State, const QRect& originalRect) const;
-    virtual int sliderLength(Qt::Orientation) const;
-    virtual int sliderThickness(Qt::Orientation) const;
-    virtual int progressBarChunkWidth(const QSize&) const;
-    virtual void getButtonMetrics(QString* buttonFontFamily, int* buttonFontPixelSize) const;
-
-    virtual QSize sizeFromContents(ContentsType, QStyleFacade::State, const QSize&) const;
-
-    virtual void paintButton(QPainter*, ButtonType, const WebCore::QStyleFacadeOption &proxyOption);
-    virtual void paintTextField(QPainter*, const WebCore::QStyleFacadeOption&);
-    virtual void paintComboBox(QPainter*, const WebCore::QStyleFacadeOption&);
-    virtual void paintComboBoxArrow(QPainter*, const WebCore::QStyleFacadeOption&);
-
-    virtual void paintSliderTrack(QPainter*, const WebCore::QStyleFacadeOption&);
-    virtual void paintSliderThumb(QPainter*, const WebCore::QStyleFacadeOption&);
-    virtual void paintInnerSpinButton(QPainter*, const WebCore::QStyleFacadeOption&, bool spinBoxUp);
-    virtual void paintProgressBar(QPainter*, const WebCore::QStyleFacadeOption&, double progress, double animationProgress);
-
-    virtual int scrollBarExtent(bool mini);
-    virtual bool scrollBarMiddleClickAbsolutePositionStyleHint() const;
-    virtual void paintScrollCorner(QPainter*, const QRect&);
-
-    virtual SubControl hitTestScrollBar(const WebCore::QStyleFacadeOption&, const QPoint& pos);
-    virtual QRect scrollBarSubControlRect(const WebCore::QStyleFacadeOption&, SubControl);
-    virtual void paintScrollBar(QPainter*, const WebCore::QStyleFacadeOption&);
-
-    virtual QObject* widgetForPainter(QPainter*);
-
-    virtual bool isValid() const { return style(); }
-
-private:
-    QStyle* style() const;
-
-    WebCore::Page* m_page;
-    mutable QStyle* m_style;
-    QStyle* m_fallbackStyle;
-    bool m_ownFallbackStyle;
-    mutable QScopedPointer<QLineEdit> m_lineEdit;
-};
-
-}
-
-#endif // QStyleFacadeImp_h
 #include "StyleResolver.h"
 #include "UserAgentStyleSheets.h"
 
+#include <QApplication>
+#include <QColor>
+#include <QFile>
+#include <QFontMetrics>
+#include <QLineEdit>
+#include <QMacStyle>
 #include <QPainter>
+#ifndef QT_NO_STYLE_PLASTIQUE
+#include <QPlastiqueStyle>
+#endif
+#include <QPushButton>
+#include <QStyleFactory>
+#include <QStyleOptionButton>
+#include <QStyleOptionFrameV2>
+#if ENABLE(PROGRESS_ELEMENT)
+#include <QStyleOptionProgressBarV2>
+#endif
+#include <QStyleOptionSlider>
+#include <QWidget>
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
+inline static void initStyleOption(QWidget* widget, QStyleOption& option)
+{
+    if (widget)
+        option.initFrom(widget);
+    else {
+        // If a widget is not directly available for rendering, we fallback to default
+        // value for an active widget.
+        option.state = QStyle::State_Active | QStyle::State_Enabled;
+    }
+}
+
+
 QSharedPointer<StylePainter> RenderThemeQStyle::getStylePainter(const PaintInfo& paintInfo)
 {
-    return QSharedPointer<StylePainter>(new StylePainterQStyle(this, paintInfo, /*RenderObject*/0));
+    return QSharedPointer<StylePainter>(new StylePainterQStyle(this, paintInfo));
 }
 
-StylePainterQStyle::StylePainterQStyle(RenderThemeQStyle* theme, const PaintInfo& paintInfo, RenderObject* renderObject)
+StylePainterQStyle::StylePainterQStyle(RenderThemeQStyle* theme, const PaintInfo& paintInfo)
     : StylePainter(theme, paintInfo)
-    , qStyle(theme->qStyle())
-    , appearance(NoControlPart)
 {
-    init(paintInfo.context ? paintInfo.context : 0);
-    if (renderObject)
-        appearance = theme->initializeCommonQStyleOptions(styleOption, renderObject);
+    init(paintInfo.context ? paintInfo.context : 0, theme->qStyle());
 }
 
 StylePainterQStyle::StylePainterQStyle(ScrollbarThemeQStyle* theme, GraphicsContext* context)
     : StylePainter()
-    , qStyle(theme->qStyle())
-    , appearance(NoControlPart)
 {
-    init(context);
+    init(context, theme->style());
 }
 
-void StylePainterQStyle::init(GraphicsContext* context)
+void StylePainterQStyle::init(GraphicsContext* context, QStyle* themeStyle)
 {
     painter = static_cast<QPainter*>(context->platformContext());
-    if (QObject* widget = qStyle->widgetForPainter(painter)) {
-        styleOption.palette = widget->property("palette").value<QPalette>();
-        styleOption.rect = widget->property("rect").value<QRect>();
-        styleOption.direction = static_cast<Qt::LayoutDirection>(widget->property("layoutDirection").toInt());
-    }
+    widget = 0;
+    QPaintDevice* dev = 0;
+    if (painter)
+        dev = painter->device();
+    if (dev && dev->devType() == QInternal::Widget)
+        widget = static_cast<QWidget*>(dev);
+    style = themeStyle;
 
     StylePainter::init(context);
 }
@@ -102,31 +128,37 @@ PassRefPtr<RenderTheme> RenderThemeQStyle::create(Page* page)
     return adoptRef(new RenderThemeQStyle(page));
 }
 
-static QtStyleFactoryFunction styleFactoryFunction;
-
-void RenderThemeQStyle::setStyleFactoryFunction(QtStyleFactoryFunction function)
-{
-    styleFactoryFunction = function;
-}
-
-QtStyleFactoryFunction RenderThemeQStyle::styleFactory()
-{
-    return styleFactoryFunction;
-}
-
 RenderThemeQStyle::RenderThemeQStyle(Page* page)
     : RenderThemeQt(page)
-    , m_qStyle(adoptPtr(styleFactoryFunction(page)))
+#ifndef QT_NO_LINEEDIT
+    , m_lineEdit(0)
+#endif
 {
-    int buttonPixelSize = 0;
-    m_qStyle->getButtonMetrics(&m_buttonFontFamily, &buttonPixelSize);
+    QPushButton button;
+    QFont defaultButtonFont = QApplication::font(&button);
+    m_buttonFontFamily = defaultButtonFont.family();
 #ifdef Q_WS_MAC
-    m_buttonFontPixelSize = buttonPixelSize;
+    button.setAttribute(Qt::WA_MacSmallSize);
+    QFontInfo fontInfo(defaultButtonFont);
+    m_buttonFontPixelSize = fontInfo.pixelSize();
 #endif
+
+    m_fallbackStyle = QStyleFactory::create(QLatin1String("windows"));
 }
 
 RenderThemeQStyle::~RenderThemeQStyle()
 {
+    delete m_fallbackStyle;
+#ifndef QT_NO_LINEEDIT
+    delete m_lineEdit;
+#endif
+}
+
+
+// for some widget painting, we need to fallback to Windows style
+QStyle* RenderThemeQStyle::fallbackStyle() const
+{
+    return (m_fallbackStyle) ? m_fallbackStyle : QApplication::style();
 }
 
 void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) const
@@ -143,9 +175,40 @@ void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) cons
         palette = pageClient->palette();
 }
 
+QStyle* RenderThemeQStyle::qStyle() const
+{
+    if (m_page) {
+        QWebPageClient* pageClient = m_page->chrome()->client()->platformPageClient();
+
+        if (pageClient)
+            return pageClient->style();
+    }
+
+    return QApplication::style();
+}
+
+int RenderThemeQStyle::findFrameLineWidth(QStyle* style) const
+{
+#ifndef QT_NO_LINEEDIT
+    if (!m_lineEdit)
+        m_lineEdit = new QLineEdit();
+#endif
+
+    QStyleOptionFrameV2 opt;
+    QWidget* widget = 0;
+#ifndef QT_NO_LINEEDIT
+    widget = m_lineEdit;
+#endif
+    return style->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, widget);
+}
+
 QRect RenderThemeQStyle::inflateButtonRect(const QRect& originalRect) const
 {
-    QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, originalRect);
+    QStyleOptionButton option;
+    option.state |= QStyle::State_Small;
+    option.rect = originalRect;
+
+    QRect layoutRect = qStyle()->subElementRect(QStyle::SE_PushButtonLayoutItem, &option, 0);
     if (!layoutRect.isNull()) {
         int paddingLeft = layoutRect.left() - originalRect.left();
         int paddingRight = originalRect.right() - layoutRect.right();
@@ -161,12 +224,13 @@ void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
 {
     QSize size(0, 0);
     const QFontMetrics fm(renderStyle->font().syntheticFont());
+    QStyle* style = qStyle();
 
     switch (renderStyle->appearance()) {
     case TextAreaPart:
     case SearchFieldPart:
     case TextFieldPart: {
-        int padding = m_qStyle->findFrameLineWidth();
+        int padding = findFrameLineWidth(style);
         renderStyle->setPaddingLeft(Length(padding, Fixed));
         renderStyle->setPaddingRight(Length(padding, Fixed));
         renderStyle->setPaddingTop(Length(padding, Fixed));
@@ -182,22 +246,31 @@ void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
 
     switch (renderStyle->appearance()) {
     case CheckboxPart: {
-        int checkBoxWidth = m_qStyle->simplePixelMetric(QStyleFacade::PM_IndicatorWidth, QStyleFacade::State_Small);
+        QStyleOption styleOption;
+        styleOption.state |= QStyle::State_Small;
+        int checkBoxWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &styleOption);
         checkBoxWidth *= renderStyle->effectiveZoom();
         size = QSize(checkBoxWidth, checkBoxWidth);
         break;
     }
     case RadioPart: {
-        int radioWidth = m_qStyle->simplePixelMetric(QStyleFacade::PM_ExclusiveIndicatorWidth, QStyleFacade::State_Small);
+        QStyleOption styleOption;
+        styleOption.state |= QStyle::State_Small;
+        int radioWidth = style->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &styleOption);
         radioWidth *= renderStyle->effectiveZoom();
         size = QSize(radioWidth, radioWidth);
         break;
     }
     case PushButtonPart:
     case ButtonPart: {
+        QStyleOptionButton styleOption;
+        styleOption.state |= QStyle::State_Small;
         QSize contentSize = fm.size(Qt::TextShowMnemonic, QString::fromLatin1("X"));
-        QSize pushButtonSize = m_qStyle->sizeFromContents(QStyleFacade::CT_PushButton, QStyleFacade::State_Small, contentSize);
-        QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, QRect(0, 0, pushButtonSize.width(), pushButtonSize.height()));
+        QSize pushButtonSize = style->sizeFromContents(QStyle::CT_PushButton,
+                                                       &styleOption, contentSize, 0);
+        styleOption.rect = QRect(0, 0, pushButtonSize.width(), pushButtonSize.height());
+        QRect layoutRect = style->subElementRect(QStyle::SE_PushButtonLayoutItem,
+                                                 &styleOption, 0);
 
         // If the style supports layout rects we use that, and  compensate accordingly
         // in paintButton() below.
@@ -209,8 +282,11 @@ void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
         break;
     }
     case MenulistPart: {
+        QStyleOptionComboBox styleOption;
+        styleOption.state |= QStyle::State_Small;
         int contentHeight = qMax(fm.lineSpacing(), 14) + 2;
-        QSize menuListSize = m_qStyle->sizeFromContents(QStyleFacade::CT_ComboBox, QStyleFacade::State_Small, QSize(0, contentHeight));
+        QSize menuListSize = style->sizeFromContents(QStyle::CT_ComboBox,
+                                                     &styleOption, QSize(0, contentHeight), 0);
         size.setHeight(menuListSize.height());
         break;
     }
@@ -263,20 +339,26 @@ void RenderThemeQStyle::adjustButtonStyle(StyleResolver* styleResolver, RenderSt
 
 void RenderThemeQStyle::setButtonPadding(RenderStyle* style) const
 {
+    QStyleOptionButton styleOption;
+    styleOption.state |= QStyle::State_Small;
+
     // Fake a button rect here, since we're just computing deltas
     QRect originalRect = QRect(0, 0, 100, 30);
+    styleOption.rect = originalRect;
 
     // Default padding is based on the button margin pixel metric
-    int buttonMargin = m_qStyle->buttonMargin(QStyleFacade::State_Small, originalRect);
+    int buttonMargin = qStyle()->pixelMetric(QStyle::PM_ButtonMargin, &styleOption, 0);
     int paddingLeft = buttonMargin;
     int paddingRight = buttonMargin;
     int paddingTop = buttonMargin;
     int paddingBottom = buttonMargin;
 
     // Then check if the style uses layout margins
-    QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, originalRect);
+    QRect layoutRect = qStyle()->subElementRect(QStyle::SE_PushButtonLayoutItem,
+                                                &styleOption, 0);
     if (!layoutRect.isNull()) {
-        QRect contentsRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonContents, QStyleFacade::State_Small, originalRect);
+        QRect contentsRect = qStyle()->subElementRect(QStyle::SE_PushButtonContents,
+                                                      &styleOption, 0);
         paddingLeft = contentsRect.left() - layoutRect.left();
         paddingRight = layoutRect.right() - contentsRect.right();
         paddingTop = contentsRect.top() - layoutRect.top();
@@ -292,42 +374,50 @@ void RenderThemeQStyle::setButtonPadding(RenderStyle* style) const
 
 bool RenderThemeQStyle::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
 {
-    StylePainterQStyle p(this, i, o);
+    StylePainterQStyle p(this, i);
     if (!p.isValid())
-        return true;
-
-    p.styleOption.rect = r;
-    p.styleOption.state |= QStyleFacade::State_Small;
-
-    if (p.appearance == PushButtonPart || p.appearance == ButtonPart) {
-        p.styleOption.rect = inflateButtonRect(p.styleOption.rect);
-        p.paintButton(QStyleFacade::PushButton);
-    } else if (p.appearance == RadioPart)
-        p.paintButton(QStyleFacade::RadioButton);
-    else if (p.appearance == CheckboxPart)
-        p.paintButton(QStyleFacade::CheckBox);
+       return true;
+
+    QStyleOptionButton option;
+    initStyleOption(p.widget, option);
+    option.rect = r;
+    option.state |= QStyle::State_Small;
+
+    ControlPart appearance = initializeCommonQStyleOptions(option, o);
+    if (appearance == PushButtonPart || appearance == ButtonPart) {
+        option.rect = inflateButtonRect(option.rect);
+        p.drawControl(QStyle::CE_PushButton, option);
+    } else if (appearance == RadioPart)
+       p.drawControl(QStyle::CE_RadioButton, option);
+    else if (appearance == CheckboxPart)
+       p.drawControl(QStyle::CE_CheckBox, option);
 
     return false;
 }
 
 bool RenderThemeQStyle::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r)
 {
-    StylePainterQStyle p(this, i, o);
+    StylePainterQStyle p(this, i);
     if (!p.isValid())
         return true;
 
-    p.styleOption.rect = r;
-    p.styleOption.state |= QStyleFacade::State_Sunken;
+    QStyleOptionFrameV2 panel;
+    initStyleOption(p.widget, panel);
+    panel.rect = r;
+    panel.lineWidth = findFrameLineWidth(qStyle());
+    panel.state |= QStyle::State_Sunken;
+    panel.features = QStyleOptionFrameV2::None;
 
     // Get the correct theme data for a text field
-    if (p.appearance != TextFieldPart
-        && p.appearance != SearchFieldPart
-        && p.appearance != TextAreaPart
-        && p.appearance != ListboxPart)
+    ControlPart appearance = initializeCommonQStyleOptions(panel, o);
+    if (appearance != TextFieldPart
+        && appearance != SearchFieldPart
+        && appearance != TextAreaPart
+        && appearance != ListboxPart)
         return true;
 
     // Now paint the text field.
-    p.paintTextField();
+    p.drawPrimitive(QStyle::PE_PanelLineEdit, panel);
     return false;
 }
 
@@ -348,7 +438,8 @@ void RenderThemeQStyle::setPopupPadding(RenderStyle* style) const
 
     style->setPaddingLeft(Length(paddingLeft, Fixed));
 
-    int w = m_qStyle->simplePixelMetric(QStyleFacade::PM_ButtonIconSize);
+    QStyleOptionComboBox opt;
+    int w = qStyle()->pixelMetric(QStyle::PM_ButtonIconSize, &opt, 0);
     style->setPaddingRight(Length(paddingRight + w, Fixed));
 
     style->setPaddingTop(Length(2, Fixed));
@@ -364,12 +455,31 @@ QPalette RenderThemeQStyle::colorPalette() const
 
 bool RenderThemeQStyle::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r)
 {
-    StylePainterQStyle p(this, i, o);
+    StylePainterQStyle p(this, i);
     if (!p.isValid())
         return true;
 
-    p.styleOption.rect = r;
-    p.paintComboBox();
+    QStyleOptionComboBox opt;
+    initStyleOption(p.widget, opt);
+    initializeCommonQStyleOptions(opt, o);
+
+    IntRect rect = r;
+
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+    // QMacStyle makes the combo boxes a little bit smaller to leave space for the focus rect.
+    // Because of it, the combo button is drawn at a point to the left of where it was expect to be and may end up
+    // overlapped with the text. This will force QMacStyle to draw the combo box with the expected width.
+    if (qobject_cast<QMacStyle*>(p.style))
+        rect.inflateX(3);
+#endif
+
+    const QPoint topLeft = rect.location();
+    p.painter->translate(topLeft);
+    opt.rect.moveTo(QPoint(0, 0));
+    opt.rect.setSize(rect.size());
+
+    p.drawComplexControl(QStyle::CC_ComboBox, opt);
+    p.painter->translate(-topLeft);
     return false;
 }
 
@@ -382,14 +492,23 @@ void RenderThemeQStyle::adjustMenuListButtonStyle(StyleResolver* styleResolver,
     RenderThemeQt::adjustMenuListButtonStyle(styleResolver, style, e);
 }
 
-bool RenderThemeQStyle::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
+bool RenderThemeQStyle::paintMenuListButton(RenderObject* o, const PaintInfo& i,
+                                        const IntRect& r)
 {
-    StylePainterQStyle p(this, i, o);
+    StylePainterQStyle p(this, i);
     if (!p.isValid())
         return true;
 
-    p.styleOption.rect = r;
-    p.paintComboBoxArrow();
+    QStyleOptionComboBox option;
+    initStyleOption(p.widget, option);
+    initializeCommonQStyleOptions(option, o);
+    option.rect = r;
+
+    // for drawing the combo box arrow, rely only on the fallback style
+    p.style = fallbackStyle();
+    option.subControls = QStyle::SC_ComboBoxArrow;
+    p.drawComplexControl(QStyle::CC_ComboBox, option);
+
     return false;
 }
 
@@ -399,10 +518,11 @@ double RenderThemeQStyle::animationDurationForProgressBar(RenderProgress* render
     if (renderProgress->position() >= 0)
         return 0;
 
-    IntSize size = renderProgress->pixelSnappedSize();
+    QStyleOptionProgressBarV2 option;
+    option.rect.setSize(renderProgress->pixelSnappedSize());
     // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed,
     // we simulate one square animating across the progress bar.
-    return (size.width() / m_qStyle->progressBarChunkWidth(size)) * animationRepeatIntervalForProgressBar(renderProgress);
+    return (option.rect.width() / qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option)) * animationRepeatIntervalForProgressBar(renderProgress);
 }
 
 bool RenderThemeQStyle::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r)
@@ -410,51 +530,86 @@ bool RenderThemeQStyle::paintProgressBar(RenderObject* o, const PaintInfo& pi, c
     if (!o->isProgress())
         return true;
 
-    StylePainterQStyle p(this, pi, o);
+    StylePainterQStyle p(this, pi);
     if (!p.isValid())
-        return true;
+       return true;
+
+    QStyleOptionProgressBarV2 option;
+    initStyleOption(p.widget, option);
+    initializeCommonQStyleOptions(option, o);
 
-    p.styleOption.rect = r;
     RenderProgress* renderProgress = toRenderProgress(o);
-    p.paintProgressBar(renderProgress->position(), renderProgress->animationProgress());
+    option.rect = r;
+    option.maximum = std::numeric_limits<int>::max();
+    option.minimum = 0;
+    option.progress = (renderProgress->position() * std::numeric_limits<int>::max());
+
+    const QPoint topLeft = r.location();
+    p.painter->translate(topLeft);
+    option.rect.moveTo(QPoint(0, 0));
+    option.rect.setSize(r.size());
+
+    if (option.progress < 0) {
+        // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed,
+        // we simulate one square animating across the progress bar.
+        p.drawControl(QStyle::CE_ProgressBarGroove, option);
+        int chunkWidth = qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option);
+        QColor color = (option.palette.highlight() == option.palette.background()) ? option.palette.color(QPalette::Active, QPalette::Highlight) : option.palette.color(QPalette::Highlight);
+        if (renderProgress->style()->direction() == RTL)
+            p.painter->fillRect(option.rect.right() - chunkWidth  - renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color);
+        else
+            p.painter->fillRect(renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color);
+    } else
+        p.drawControl(QStyle::CE_ProgressBar, option);
+
+    p.painter->translate(-topLeft);
+
     return false;
 }
 #endif
 
-bool RenderThemeQStyle::paintSliderTrack(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+bool RenderThemeQStyle::paintSliderTrack(RenderObject* o, const PaintInfo& pi,
+                                     const IntRect& r)
 {
-    StylePainterQStyle p(this, pi, o);
+    StylePainterQStyle p(this, pi);
     if (!p.isValid())
         return true;
 
     const QPoint topLeft = r.location();
     p.painter->translate(topLeft);
 
-    p.styleOption.rect = r;
-    p.styleOption.rect.moveTo(QPoint(0, 0));
-
-    if (p.appearance == SliderVerticalPart)
-        p.styleOption.slider.orientation = Qt::Vertical;
-
+    QStyleOptionSlider option;
+    initStyleOption(p.widget, option);
+    option.subControls = QStyle::SC_SliderGroove;
+    ControlPart appearance = initializeCommonQStyleOptions(option, o);
+    option.rect = r;
+    option.rect.moveTo(QPoint(0, 0));
+    if (appearance == SliderVerticalPart)
+        option.orientation = Qt::Vertical;
     if (isPressed(o))
-        p.styleOption.state |= QStyleFacade::State_Sunken;
+        option.state |= QStyle::State_Sunken;
 
     // some styles need this to show a highlight on one side of the groove
     HTMLInputElement* slider = o->node()->toInputElement();
     if (slider) {
-        p.styleOption.slider.upsideDown = (p.appearance == SliderHorizontalPart) && !o->style()->isLeftToRightDirection();
+        option.upsideDown = (appearance == SliderHorizontalPart) && !o->style()->isLeftToRightDirection();
         // Use the width as a multiplier in case the slider values are <= 1
         const int width = r.width() > 0 ? r.width() : 100;
-        p.styleOption.slider.maximum = slider->maximum() * width;
-        p.styleOption.slider.minimum = slider->minimum() * width;
-        if (!p.styleOption.slider.upsideDown)
-            p.styleOption.slider.position = slider->valueAsNumber() * width;
+        option.maximum = slider->maximum() * width;
+        option.minimum = slider->minimum() * width;
+        if (!option.upsideDown)
+            option.sliderPosition = slider->valueAsNumber() * width;
         else
-            p.styleOption.slider.position = p.styleOption.slider.minimum + p.styleOption.slider.maximum - slider->valueAsNumber() * width;
+            option.sliderPosition = option.minimum + option.maximum - slider->valueAsNumber() * width;
     }
 
-    p.paintSliderTrack();
+    p.drawComplexControl(QStyle::CC_Slider, option);
 
+    if (option.state & QStyle::State_HasFocus) {
+        QStyleOptionFocusRect focusOption;
+        focusOption.rect = r;
+        p.drawPrimitive(QStyle::PE_FrameFocusRect, focusOption);
+    }
     p.painter->translate(-topLeft);
     return false;
 }
@@ -464,25 +619,30 @@ void RenderThemeQStyle::adjustSliderTrackStyle(StyleResolver*, RenderStyle* styl
     style->setBoxShadow(nullptr);
 }
 
-bool RenderThemeQStyle::paintSliderThumb(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+bool RenderThemeQStyle::paintSliderThumb(RenderObject* o, const PaintInfo& pi,
+                                     const IntRect& r)
 {
-    StylePainterQStyle p(this, pi, o);
+    StylePainterQStyle p(this, pi);
     if (!p.isValid())
         return true;
 
     const QPoint topLeft = r.location();
     p.painter->translate(topLeft);
 
-    p.styleOption.rect = r;
-    p.styleOption.rect.moveTo(QPoint(0, 0));
-    p.styleOption.slider.orientation = Qt::Horizontal;
-    if (p.appearance == SliderThumbVerticalPart)
-        p.styleOption.slider.orientation = Qt::Vertical;
-    if (isPressed(o))
-        p.styleOption.state |= QStyleFacade::State_Sunken;
-
-    p.paintSliderThumb();
+    QStyleOptionSlider option;
+    initStyleOption(p.widget, option);
+    option.subControls = QStyle::SC_SliderHandle;
+    ControlPart appearance = initializeCommonQStyleOptions(option, o);
+    option.rect = r;
+    option.rect.moveTo(QPoint(0, 0));
+    if (appearance == SliderThumbVerticalPart)
+        option.orientation = Qt::Vertical;
+    if (isPressed(o)) {
+        option.activeSubControls = QStyle::SC_SliderHandle;
+        option.state |= QStyle::State_Sunken;
+    }
 
+    p.drawComplexControl(QStyle::CC_Slider, option);
     p.painter->translate(-topLeft);
     return false;
 }
@@ -493,7 +653,8 @@ void RenderThemeQStyle::adjustSliderThumbStyle(StyleResolver* styleResolver, Ren
     style->setBoxShadow(nullptr);
 }
 
-bool RenderThemeQStyle::paintSearchField(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+bool RenderThemeQStyle::paintSearchField(RenderObject* o, const PaintInfo& pi,
+                                     const IntRect& r)
 {
     return paintTextField(o, pi, r);
 }
@@ -504,7 +665,8 @@ void RenderThemeQStyle::adjustSearchFieldDecorationStyle(StyleResolver* styleRes
     RenderTheme::adjustSearchFieldDecorationStyle(styleResolver, style, e);
 }
 
-bool RenderThemeQStyle::paintSearchFieldDecoration(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+bool RenderThemeQStyle::paintSearchFieldDecoration(RenderObject* o, const PaintInfo& pi,
+                                               const IntRect& r)
 {
     notImplemented();
     return RenderTheme::paintSearchFieldDecoration(o, pi, r);
@@ -516,7 +678,8 @@ void RenderThemeQStyle::adjustSearchFieldResultsDecorationStyle(StyleResolver* s
     RenderTheme::adjustSearchFieldResultsDecorationStyle(styleResolver, style, e);
 }
 
-bool RenderThemeQStyle::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+bool RenderThemeQStyle::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& pi,
+                                                      const IntRect& r)
 {
     notImplemented();
     return RenderTheme::paintSearchFieldResultsDecoration(o, pi, r);
@@ -526,35 +689,78 @@ bool RenderThemeQStyle::paintSearchFieldResultsDecoration(RenderObject* o, const
 
 bool RenderThemeQStyle::paintInnerSpinButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    StylePainterQStyle p(this, paintInfo, o);
+    StylePainterQStyle p(this, paintInfo);
     if (!p.isValid())
-        return true;
+       return true;
+
+    QStyleOptionSpinBox option;
+    initStyleOption(p.widget, option);
+    option.subControls = QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown;
+    if (!isReadOnlyControl(o)) {
+        if (isEnabled(o))
+            option.stepEnabled = QAbstractSpinBox::StepUpEnabled | QAbstractSpinBox::StepDownEnabled;
+        if (isPressed(o)) {
+            option.state |= QStyle::State_Sunken;
+            if (isSpinUpButtonPartPressed(o))
+                option.activeSubControls = QStyle::SC_SpinBoxUp;
+            else
+                option.activeSubControls = QStyle::SC_SpinBoxDown;
+        }
+    }
+    // Render the spin buttons for LTR or RTL accordingly.
+    option.direction = o->style()->isLeftToRightDirection() ? Qt::LeftToRight : Qt::RightToLeft;
+
+    IntRect buttonRect = rect;
+    // Default to moving the buttons a little bit within the editor frame.
+    int inflateX = -2;
+    int inflateY = -2;
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+    // QMacStyle will position the aqua buttons flush to the right.
+    // This will move them more within the control for better style, a la
+    // Chromium look & feel.
+    if (qobject_cast<QMacStyle*>(p.style)) {
+        inflateX = -4;
+        // Render mini aqua spin buttons for QMacStyle to fit nicely into
+        // the editor area, like Chromium.
+        option.state |= QStyle::State_Mini;
+    }
+#endif
+#if !defined(QT_NO_STYLE_PLASTIQUE)
+    // QPlastiqueStyle looks best when the spin buttons are flush with the frame's edge.
+    if (qobject_cast<QPlastiqueStyle*>(p.style)) {
+        inflateX = 0;
+        inflateY = 0;
+    }
+#endif
 
-    p.styleOption.rect = rect;
-    p.paintInnerSpinButton(isSpinUpButtonPartPressed(o));
+    buttonRect.inflateX(inflateX);
+    buttonRect.inflateY(inflateY);
+    option.rect = buttonRect;
+
+    p.drawComplexControl(QStyle::CC_SpinBox, option);
     return false;
 }
 #endif
 
-ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleFacadeOption &option, RenderObject* o) const
+ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleOption& option, RenderObject* o) const
 {
     // Default bits: no focus, no mouse over
-    option.state &= ~(QStyleFacade::State_HasFocus | QStyleFacade::State_MouseOver);
+    option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
 
     if (isReadOnlyControl(o))
         // Readonly is supported on textfields.
-        option.state |= QStyleFacade::State_ReadOnly;
+        option.state |= QStyle::State_ReadOnly;
 
     option.direction = Qt::LeftToRight;
 
     if (isHovered(o))
-        option.state |= QStyleFacade::State_MouseOver;
+        option.state |= QStyle::State_MouseOver;
 
     setPaletteFromPageClientIfExists(option.palette);
 
     if (!isEnabled(o)) {
         option.palette.setCurrentColorGroup(QPalette::Disabled);
-        option.state &= ~QStyleFacade::State_Enabled;
+        option.state &= ~QStyle::State_Enabled;
     }
 
     RenderStyle* style = o->style();
@@ -563,8 +769,8 @@ ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleFacadeOption
 
     ControlPart result = style->appearance();
     if (supportsFocus(result) && isFocused(o)) {
-        option.state |= QStyleFacade::State_HasFocus;
-        option.state |= QStyleFacade::State_KeyboardFocusChange;
+        option.state |= QStyle::State_HasFocus;
+        option.state |= QStyle::State_KeyboardFocusChange;
     }
 
     if (style->direction() == WebCore::RTL)
@@ -577,18 +783,17 @@ ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleFacadeOption
     case ButtonBevelPart:
     case ListItemPart:
     case MenulistButtonPart:
-    case InnerSpinButtonPart:
     case SearchFieldResultsButtonPart:
     case SearchFieldCancelButtonPart: {
         if (isPressed(o))
-            option.state |= QStyleFacade::State_Sunken;
+            option.state |= QStyle::State_Sunken;
         else if (result == PushButtonPart || result == ButtonPart)
-            option.state |= QStyleFacade::State_Raised;
+            option.state |= QStyle::State_Raised;
         break;
     }
     case RadioPart:
     case CheckboxPart:
-        option.state |= (isChecked(o) ? QStyleFacade::State_On : QStyleFacade::State_Off);
+        option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off);
     }
 
     return result;
@@ -598,13 +803,15 @@ void RenderThemeQStyle::adjustSliderThumbSize(RenderStyle* style, Element* eleme
 {
     const ControlPart part = style->appearance();
     if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) {
-        Qt::Orientation orientation = Qt::Horizontal;
+        QStyleOptionSlider option;
         if (part == SliderThumbVerticalPart)
-            orientation = Qt::Vertical;
+            option.orientation = Qt::Vertical;
+
+        QStyle* qstyle = qStyle();
 
-        int length = m_qStyle->sliderLength(orientation);
-        int thickness = m_qStyle->sliderThickness(orientation);
-        if (orientation == Qt::Vertical) {
+        int length = qstyle->pixelMetric(QStyle::PM_SliderLength, &option);
+        int thickness = qstyle->pixelMetric(QStyle::PM_SliderThickness, &option);
+        if (option.orientation == Qt::Vertical) {
             style->setWidth(Length(thickness, Fixed));
             style->setHeight(Length(length, Fixed));
         } else {
 #ifndef RenderThemeQStyle_h
 #define RenderThemeQStyle_h
 
-#include "QStyleFacade.h"
 #include "RenderThemeQt.h"
 
-namespace WebCore {
+#include <QStyle>
 
-class ScrollbarThemeQStyle;
+QT_BEGIN_NAMESPACE
+#ifndef QT_NO_LINEEDIT
+class QLineEdit;
+#endif
+class QPainter;
+class QWidget;
+QT_END_NAMESPACE
 
-class Page;
-class QStyleFacade;
-struct QStyleFacadeOption;
+namespace WebCore {
 
-typedef QStyleFacade* (*QtStyleFactoryFunction)(Page*);
+class ScrollbarThemeQStyle;
 
 class RenderThemeQStyle : public RenderThemeQt {
 private:
-    friend class StylePainterQStyle;
-
     RenderThemeQStyle(Page*);
     virtual ~RenderThemeQStyle();
 
 public:
     static PassRefPtr<RenderTheme> create(Page*);
 
-    static void setStyleFactoryFunction(QtStyleFactoryFunction);
-    static QtStyleFactoryFunction styleFactory();
-
     virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
 
-    QStyleFacade* qStyle() { return m_qStyle.get(); }
+    QStyle* qStyle() const;
 
 protected:
     virtual void adjustButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
@@ -102,53 +100,45 @@ protected:
     virtual QPalette colorPalette() const;
 
 private:
-    ControlPart initializeCommonQStyleOptions(QStyleFacadeOption&, RenderObject*) const;
+    ControlPart initializeCommonQStyleOptions(QStyleOption&, RenderObject*) const;
 
     void setButtonPadding(RenderStyle*) const;
 
+    int findFrameLineWidth(QStyle*) const;
+
+    QStyle* fallbackStyle() const;
+
     void setPaletteFromPageClientIfExists(QPalette&) const;
 
 #ifdef Q_OS_MAC
     int m_buttonFontPixelSize;
 #endif
 
-    OwnPtr<QStyleFacade> m_qStyle;
+    QStyle* m_fallbackStyle;
+#ifndef QT_NO_LINEEDIT
+    mutable QLineEdit* m_lineEdit;
+#endif
 };
 
 class StylePainterQStyle : public StylePainter {
 public:
-    explicit StylePainterQStyle(RenderThemeQStyle*, const PaintInfo&, RenderObject*);
+    explicit StylePainterQStyle(RenderThemeQStyle*, const PaintInfo&);
     explicit StylePainterQStyle(ScrollbarThemeQStyle*, GraphicsContext*);
 
-    bool isValid() const { return qStyle && qStyle->isValid() && StylePainter::isValid(); }
-
-    QStyleFacade* qStyle;
-    QStyleFacadeOption styleOption;
-    ControlPart appearance;
-
-    void paintButton(QStyleFacade::ButtonType type)
-    { qStyle->paintButton(painter, type, styleOption); }
-    void paintTextField()
-    { qStyle->paintTextField(painter, styleOption); }
-    void paintComboBox()
-    { qStyle->paintComboBox(painter, styleOption); }
-    void paintComboBoxArrow()
-    { qStyle->paintComboBoxArrow(painter, styleOption); }
-    void paintSliderTrack()
-    { qStyle->paintSliderTrack(painter, styleOption); }
-    void paintSliderThumb()
-    { qStyle->paintSliderThumb(painter, styleOption); }
-    void paintInnerSpinButton(bool spinBoxUp)
-    { qStyle->paintInnerSpinButton(painter, styleOption, spinBoxUp); }
-    void paintProgressBar(double progress, double animationProgress)
-    { qStyle->paintProgressBar(painter, styleOption, progress, animationProgress); }
-    void paintScrollCorner(const QRect& rect)
-    { qStyle->paintScrollCorner(painter, rect); }
-    void paintScrollBar()
-    { qStyle->paintScrollBar(painter, styleOption); }
+    bool isValid() const { return style && StylePainter::isValid(); }
+
+    QWidget* widget;
+    QStyle* style;
+
+    void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption& opt)
+    { style->drawPrimitive(pe, &opt, painter, widget); }
+    void drawControl(QStyle::ControlElement ce, const QStyleOption& opt)
+    { style->drawControl(ce, &opt, painter, widget); }
+    void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex& opt)
+    { style->drawComplexControl(cc, &opt, painter, widget); }
 
 private:
-    void init(GraphicsContext*);
+    void init(GraphicsContext*, QStyle*);
 
     Q_DISABLE_COPY(StylePainterQStyle)
 };
 #include "GraphicsContext.h"
 #include "PlatformMouseEvent.h"
 #include "RenderThemeQStyle.h"
+#include "RenderThemeQtMobile.h"
 #include "ScrollView.h"
 #include "Scrollbar.h"
 
-namespace WebCore {
+#include <QApplication>
+#ifdef Q_WS_MAC
+#include <QMacStyle>
+#endif
+#include <QMenu>
+#include <QPainter>
+#include <QStyle>
+#include <QStyleOptionSlider>
 
-ScrollbarThemeQStyle::ScrollbarThemeQStyle()
-{
-    m_qStyle = adoptPtr(RenderThemeQStyle::styleFactory()(/*page*/ 0));
-}
+namespace WebCore {
 
 ScrollbarThemeQStyle::~ScrollbarThemeQStyle()
 {
 }
 
-static QStyleFacade::SubControl scPart(const ScrollbarPart& part)
+static QStyle::SubControl scPart(const ScrollbarPart& part)
 {
     switch (part) {
     case NoPart:
-        return QStyleFacade::SC_None;
+        return QStyle::SC_None;
     case BackButtonStartPart:
     case BackButtonEndPart:
-        return QStyleFacade::SC_ScrollBarSubLine;
+        return QStyle::SC_ScrollBarSubLine;
     case BackTrackPart:
-        return QStyleFacade::SC_ScrollBarSubPage;
+        return QStyle::SC_ScrollBarSubPage;
     case ThumbPart:
-        return QStyleFacade::SC_ScrollBarSlider;
+        return QStyle::SC_ScrollBarSlider;
     case ForwardTrackPart:
-        return QStyleFacade::SC_ScrollBarAddPage;
+        return QStyle::SC_ScrollBarAddPage;
     case ForwardButtonStartPart:
     case ForwardButtonEndPart:
-        return QStyleFacade::SC_ScrollBarAddLine;
+        return QStyle::SC_ScrollBarAddLine;
     }
 
-    return QStyleFacade::SC_None;
+    return QStyle::SC_None;
 }
 
-static ScrollbarPart scrollbarPart(const QStyleFacade::SubControl& sc)
+static ScrollbarPart scrollbarPart(const QStyle::SubControl& sc)
 {
     switch (sc) {
-    case QStyleFacade::SC_None:
+    case QStyle::SC_None:
         return NoPart;
-    case QStyleFacade::SC_ScrollBarSubLine:
+    case QStyle::SC_ScrollBarSubLine:
         return BackButtonStartPart;
-    case QStyleFacade::SC_ScrollBarSubPage:
+    case QStyle::SC_ScrollBarSubPage:
         return BackTrackPart;
-    case QStyleFacade::SC_ScrollBarSlider:
+    case QStyle::SC_ScrollBarSlider:
         return ThumbPart;
-    case QStyleFacade::SC_ScrollBarAddPage:
+    case QStyle::SC_ScrollBarAddPage:
         return ForwardTrackPart;
-    case QStyleFacade::SC_ScrollBarAddLine:
+    case QStyle::SC_ScrollBarAddLine:
         return ForwardButtonStartPart;
     }
     return NoPart;
 }
 
-static QStyleFacadeOption initSliderStyleOption(ScrollbarThemeClient* scrollbar, QObject* widget = 0)
+static QStyleOptionSlider* styleOptionSlider(ScrollbarThemeClient* scrollbar, QWidget* widget = 0)
 {
-    QStyleFacadeOption opt;
-    if (widget) {
-        opt.palette = widget->property("palette").value<QPalette>();
-        opt.rect = widget->property("rect").value<QRect>();
-        opt.direction = static_cast<Qt::LayoutDirection>(widget->property("layoutDirection").toInt());
-    } else
-        opt.state |= QStyleFacade::State_Active;
+    static QStyleOptionSlider opt;
+    if (widget)
+        opt.initFrom(widget);
+    else
+        opt.state |= QStyle::State_Active;
 
-    opt.state &= ~QStyleFacade::State_HasFocus;
+    opt.state &= ~QStyle::State_HasFocus;
 
     opt.rect = scrollbar->frameRect();
     if (scrollbar->enabled())
-        opt.state |= QStyleFacade::State_Enabled;
+        opt.state |= QStyle::State_Enabled;
     if (scrollbar->controlSize() != RegularScrollbar)
-        opt.state |= QStyleFacade::State_Mini;
-    opt.slider.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;
+        opt.state |= QStyle::State_Mini;
+    opt.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;
 
     if (scrollbar->orientation() == HorizontalScrollbar)
-        opt.state |= QStyleFacade::State_Horizontal;
+        opt.state |= QStyle::State_Horizontal;
     else
-        opt.state &= ~QStyleFacade::State_Horizontal;
-
-    opt.slider.value = scrollbar->value();
-    opt.slider.position = opt.slider.value;
-    opt.slider.pageStep = scrollbar->pageStep();
-    opt.slider.singleStep = scrollbar->lineStep();
-    opt.slider.minimum = 0;
-    opt.slider.maximum = qMax(0, scrollbar->maximum());
+        opt.state &= ~QStyle::State_Horizontal;
+
+    opt.sliderValue = scrollbar->value();
+    opt.sliderPosition = opt.sliderValue;
+    opt.pageStep = scrollbar->pageStep();
+    opt.singleStep = scrollbar->lineStep();
+    opt.minimum = 0;
+    opt.maximum = qMax(0, scrollbar->maximum());
     ScrollbarPart pressedPart = scrollbar->pressedPart();
     ScrollbarPart hoveredPart = scrollbar->hoveredPart();
     if (pressedPart != NoPart) {
-        opt.slider.activeSubControls = scPart(scrollbar->pressedPart());
+        opt.activeSubControls = scPart(scrollbar->pressedPart());
         if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart
             || pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart
             || pressedPart == ThumbPart)
-            opt.state |= QStyleFacade::State_Sunken;
+            opt.state |= QStyle::State_Sunken;
     } else
-        opt.slider.activeSubControls = scPart(hoveredPart);
+        opt.activeSubControls = scPart(hoveredPart);
     if (hoveredPart != NoPart)
-        opt.state |= QStyleFacade::State_MouseOver;
-    return opt;
+        opt.state |= QStyle::State_MouseOver;
+    return &opt;
 }
 
 bool ScrollbarThemeQStyle::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& dirtyRect)
 {
     if (graphicsContext->updatingControlTints()) {
-        scrollbar->invalidateRect(dirtyRect);
-        return false;
+       scrollbar->invalidateRect(dirtyRect);
+       return false;
     }
 
     StylePainterQStyle p(this, graphicsContext);
     if (!p.isValid())
-        return true;
+      return true;
 
     p.painter->save();
-    p.styleOption = initSliderStyleOption(scrollbar, m_qStyle->widgetForPainter(p.painter));
+    QStyleOptionSlider* opt = styleOptionSlider(scrollbar, p.widget);
+
+    p.painter->setClipRect(opt->rect.intersected(dirtyRect), Qt::IntersectClip);
 
-    p.painter->setClipRect(p.styleOption.rect.intersected(dirtyRect), Qt::IntersectClip);
-    p.paintScrollBar();
+#ifdef Q_WS_MAC
+    // FIXME: We also need to check the widget style but today ScrollbarTheme is not aware of the page so we
+    // can't get the widget.
+    if (qobject_cast<QMacStyle*>(style()))
+        p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
+    else
+#endif
+    {
+        // The QStyle expects the background to be already filled.
+        p.painter->fillRect(opt->rect, opt->palette.background());
+
+        const QPoint topLeft = opt->rect.topLeft();
+        p.painter->translate(topLeft);
+        opt->rect.moveTo(QPoint(0, 0));
+        p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
+        opt->rect.moveTo(topLeft);
+    }
     p.painter->restore();
+
     return true;
 }
 
 ScrollbarPart ScrollbarThemeQStyle::hitTest(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt)
 {
-    QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
+    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
     const QPoint pos = scrollbar->convertFromContainingWindow(evt.position());
-    opt.rect.moveTo(QPoint(0, 0));
-    QStyleFacade::SubControl sc = m_qStyle->hitTestScrollBar(opt, pos);
+    opt->rect.moveTo(QPoint(0, 0));
+    QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0);
     return scrollbarPart(sc);
 }
 
 bool ScrollbarThemeQStyle::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt)
 {
     // Middle click centers slider thumb (if supported).
-    return m_qStyle->scrollBarMiddleClickAbsolutePositionStyleHint() && evt.button() == MiddleButton;
+    return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
 }
 
 void ScrollbarThemeQStyle::invalidatePart(ScrollbarThemeClient* scrollbar, ScrollbarPart)
@@ -174,8 +195,12 @@ void ScrollbarThemeQStyle::invalidatePart(ScrollbarThemeClient* scrollbar, Scrol
 
 int ScrollbarThemeQStyle::scrollbarThickness(ScrollbarControlSize controlSize)
 {
-    const bool mini = controlSize != RegularScrollbar;
-    return m_qStyle->scrollBarExtent(mini);
+    QStyleOptionSlider o;
+    o.orientation = Qt::Vertical;
+    o.state &= ~QStyle::State_Horizontal;
+    if (controlSize != RegularScrollbar)
+        o.state |= QStyle::State_Mini;
+    return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
 }
 
 int ScrollbarThemeQStyle::thumbPosition(ScrollbarThemeClient* scrollbar)
@@ -189,22 +214,22 @@ int ScrollbarThemeQStyle::thumbPosition(ScrollbarThemeClient* scrollbar)
 
 int ScrollbarThemeQStyle::thumbLength(ScrollbarThemeClient* scrollbar)
 {
-    QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
-    QRect thumb = m_qStyle->scrollBarSubControlRect(opt, QStyleFacade::SC_ScrollBarSlider);
+    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
+    IntRect thumb = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0);
     return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height();
 }
 
 int ScrollbarThemeQStyle::trackPosition(ScrollbarThemeClient* scrollbar)
 {
-    QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
-    QRect track = m_qStyle->scrollBarSubControlRect(opt, QStyleFacade::SC_ScrollBarGroove);
+    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
+    IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
     return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y();
 }
 
 int ScrollbarThemeQStyle::trackLength(ScrollbarThemeClient* scrollbar)
 {
-    QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
-    QRect track = m_qStyle->scrollBarSubControlRect(opt, QStyleFacade::SC_ScrollBarGroove);
+    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
+    IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
     return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height();
 }
 
@@ -214,7 +239,14 @@ void ScrollbarThemeQStyle::paintScrollCorner(ScrollView*, GraphicsContext* conte
     if (!p.isValid())
         return;
 
-    p.paintScrollCorner(rect);
+    QStyleOption option;
+    option.rect = rect;
+    p.drawPrimitive(QStyle::PE_PanelScrollAreaCorner, option);
+}
+
+QStyle* ScrollbarThemeQStyle::style() const
+{
+    return QApplication::style();
 }
 
 }
 
 #include <QtCore/qglobal.h>
 
-namespace WebCore {
+QT_BEGIN_NAMESPACE
+class QStyle;
+QT_END_NAMESPACE
 
-class QStyleFacade;
+namespace WebCore {
 
 class ScrollbarThemeQStyle : public ScrollbarTheme {
 public:
-    ScrollbarThemeQStyle();
     virtual ~ScrollbarThemeQStyle();
 
     virtual bool paint(ScrollbarThemeClient*, GraphicsContext*, const IntRect& dirtyRect);
@@ -55,10 +56,7 @@ public:
 
     virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
 
-    QStyleFacade* qStyle() { return m_qStyle.get(); }
-
-private:
-    OwnPtr<QStyleFacade> m_qStyle;
+    QStyle* style() const;
 };
 
 }