Changeset 109542 in webkit


Ignore:
Timestamp:
Mar 2, 2012 2:43:22 AM (12 years ago)
Author:
Simon Hausmann
Message:

[Qt] Move QStyle theming code out of WebCore into WebKit1
https://bugs.webkit.org/show_bug.cgi?id=80128

Reviewed by Kenneth Rohde Christiansen.

.:

  • Source/api.pri: Adjust to moving source files.

Source/WebCore:

Moved QStyle dependant code into WebKit1, where it's okay to depend on
QtWidgets/QStyle. Added factory hooks into RenderThemeQt to allow changing
the default "mobile" style to QStyle on start-up.

  • Target.pri:
  • platform/qt/RenderThemeQt.cpp:

(WebCore):
(WebCore::RenderThemeQt::setCustomTheme):
(WebCore::RenderThemeQt::customScrollbarTheme):
(WebCore::createTheme):
(WebCore::RenderTheme::themeForPage):
(WebCore::RenderThemeQt::extraDefaultStyleSheet):

  • platform/qt/RenderThemeQt.h:

(WebCore):
(RenderThemeQt):

  • platform/qt/RenderThemeQtMobile.cpp:
  • platform/qt/ScrollbarThemeQt.cpp:

(WebCore::ScrollbarTheme::nativeTheme):

Source/WebKit/qt:

Moved the bulk of the QStyle dependant code here, where it's okay to depend on QtWidgets/QStyle.
Install the QStyle factory functions in initWebCoreQt.cpp.

  • Api/qwebpage.cpp:

(QWebPage::swallowContextMenuEvent):

  • WebCoreSupport/InitWebCoreQt.cpp:

(WebCore::initializeWebCoreQt):

  • 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::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::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: Copied from Source/WebCore/platform/qt/ScrollbarThemeQt.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/ScrollbarThemeQt.h.

(WebCore):
(ScrollbarThemeQStyle):

Location:
trunk
Files:
11 edited
1 copied
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r109418 r109542  
     12012-03-02  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        [Qt] Move QStyle theming code out of WebCore into WebKit1
     4        https://bugs.webkit.org/show_bug.cgi?id=80128
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        * Source/api.pri: Adjust to moving source files.
     9
    1102012-03-01  Ryosuke Niwa  <rniwa@webkit.org>
    211
  • trunk/Source/WebCore/ChangeLog

    r109541 r109542  
     12012-03-02  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        [Qt] Move QStyle theming code out of WebCore into WebKit1
     4        https://bugs.webkit.org/show_bug.cgi?id=80128
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Moved QStyle dependant code into WebKit1, where it's okay to depend on
     9        QtWidgets/QStyle. Added factory hooks into RenderThemeQt to allow changing
     10        the default "mobile" style to QStyle on start-up.
     11
     12        * Target.pri:
     13        * platform/qt/RenderThemeQt.cpp:
     14        (WebCore):
     15        (WebCore::RenderThemeQt::setCustomTheme):
     16        (WebCore::RenderThemeQt::customScrollbarTheme):
     17        (WebCore::createTheme):
     18        (WebCore::RenderTheme::themeForPage):
     19        (WebCore::RenderThemeQt::extraDefaultStyleSheet):
     20        * platform/qt/RenderThemeQt.h:
     21        (WebCore):
     22        (RenderThemeQt):
     23        * platform/qt/RenderThemeQtMobile.cpp:
     24        * platform/qt/ScrollbarThemeQt.cpp:
     25        (WebCore::ScrollbarTheme::nativeTheme):
     26
    1272012-03-02  Luke Macpherson   <macpherson@chromium.org>
    228
  • trunk/Source/WebCore/Target.pri

    r109538 r109542  
    28662866}
    28672867
    2868 contains(DEFINES, HAVE_QSTYLE=1) {
    2869     HEADERS += platform/qt/RenderThemeQStyle.h \
    2870                platform/qt/ScrollbarThemeQt.h
    2871     SOURCES += platform/qt/RenderThemeQStyle.cpp
    2872 }
    2873 
    28742868contains(DEFINES, ENABLE_SMOOTH_SCROLLING=1) {
    28752869    win32-*|wince* {
  • trunk/Source/WebCore/platform/qt/RenderThemeQt.cpp

    r108261 r109542  
    5555#endif
    5656#include "RenderTheme.h"
     57#include "RenderThemeQtMobile.h"
    5758#include "ScrollbarTheme.h"
    5859#include "TimeRanges.h"
     
    8384static const float defaultSearchFieldResultsButtonWidth = 18;
    8485
     86static QtThemeFactoryFunction themeFactory;
     87static ScrollbarTheme* scrollbarTheme;
     88
    8589RenderThemeQt::RenderThemeQt(Page* page)
    8690    : RenderTheme()
     
    9094}
    9195
    92 bool RenderThemeQt::useMobileTheme()
    93 {
    94 #if HAVE(QSTYLE)
    95     return !qgetenv("QT_WEBKIT_USE_MOBILE_THEME").isNull();
    96 #else
    97     return true;
    98 #endif
     96void RenderThemeQt::setCustomTheme(QtThemeFactoryFunction factory, ScrollbarTheme* customScrollbarTheme)
     97{
     98    themeFactory = factory;
     99    scrollbarTheme = customScrollbarTheme;
     100}
     101
     102ScrollbarTheme* RenderThemeQt::customScrollbarTheme()
     103{
     104    return scrollbarTheme;
     105}
     106
     107static PassRefPtr<RenderTheme> createTheme(Page* page)
     108{
     109    if (themeFactory)
     110        return themeFactory(page);
     111    return RenderThemeQtMobile::create(page);
     112}
     113
     114PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page)
     115{
     116    if (page)
     117        return createTheme(page);
     118    static RenderTheme* fallback = createTheme(0).leakRef();
     119    return fallback;
    99120}
    100121
     
    117138    StringBuilder result;
    118139    result.append(RenderTheme::extraDefaultStyleSheet());
    119     if (useMobileTheme()) {
     140    // When no theme factory is provided we default to using our platform independent "Mobile Qt" theme,
     141    // which requires the following stylesheets.
     142    if (!themeFactory) {
    120143        result.append(String(themeQtNoListboxesUserAgentStyleSheet, sizeof(themeQtNoListboxesUserAgentStyleSheet)));
    121144        result.append(String(mobileThemeQtUserAgentStyleSheet, sizeof(mobileThemeQtUserAgentStyleSheet)));
  • trunk/Source/WebCore/platform/qt/RenderThemeQt.h

    r108261 r109542  
    4141class HTMLMediaElement;
    4242class StylePainter;
     43class ScrollbarTheme;
     44
     45typedef PassRefPtr<RenderTheme> (*QtThemeFactoryFunction)(Page* page);
    4346
    4447class RenderThemeQt : public RenderTheme {
     
    4750    RenderThemeQt(Page*);
    4851
    49     static bool useMobileTheme();
     52    static void setCustomTheme(QtThemeFactoryFunction, ScrollbarTheme* customScrollbarTheme);
     53    static ScrollbarTheme* customScrollbarTheme();
    5054
    5155    String extraDefaultStyleSheet();
  • trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp

    r104834 r109542  
    4242#include "RenderProgress.h"
    4343#endif
    44 #if HAVE(QSTYLE)
    45 #include "RenderThemeQStyle.h"
    46 #endif
    47 
    4844#include <QColor>
    4945#include <QFile>
     
    551547}
    552548
    553 static PassRefPtr<RenderTheme> createTheme(Page* page)
    554 {
    555 #if HAVE(QSTYLE)
    556     if (!RenderThemeQt::useMobileTheme())
    557         return RenderThemeQStyle::create(page);
    558 #endif
    559     return RenderThemeQtMobile::create(page);
    560 }
    561 
    562 PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page)
    563 {
    564     if (page)
    565         return createTheme(page);
    566     static RenderTheme* fallback = createTheme(0).leakRef();
    567     return fallback;
    568 }
    569 
    570549RenderThemeQtMobile::RenderThemeQtMobile(Page* page)
    571550    : RenderThemeQt(page)
  • trunk/Source/WebCore/platform/qt/ScrollbarThemeQt.cpp

    r109451 r109542  
    2727
    2828#include "config.h"
    29 
    30 #if !HAVE(QSTYLE)
    3129#include "ScrollbarTheme.h"
    3230
    33 #else
    34 #include "ScrollbarThemeQt.h"
    35 
    36 #include "GraphicsContext.h"
    37 #include "PlatformMouseEvent.h"
    38 #include "RenderThemeQStyle.h"
    39 #include "RenderThemeQtMobile.h"
    40 #include "ScrollView.h"
    41 #include "Scrollbar.h"
    42 
    43 #include <QApplication>
    44 #ifdef Q_WS_MAC
    45 #include <QMacStyle>
    46 #endif
    47 #include <QMenu>
    48 #include <QPainter>
    49 #include <QStyle>
    50 #include <QStyleOptionSlider>
    51 #endif // HAVE(QSTYLE)
     31#include "RenderThemeQt.h"
    5232
    5333namespace WebCore {
     
    5838    if (theme)
    5939        return theme;
    60 #if HAVE(QSTYLE)
    61     if (!RenderThemeQt::useMobileTheme())
    62         theme = new ScrollbarThemeQt();
    63     else
    64 #endif
     40    theme = RenderThemeQt::customScrollbarTheme();
     41    if (!theme)
    6542        theme = new ScrollbarTheme();
    6643    return theme;
    6744}
    6845
    69 #if HAVE(QSTYLE)
    70 ScrollbarThemeQt::~ScrollbarThemeQt()
    71 {
    7246}
    7347
    74 static QStyle::SubControl scPart(const ScrollbarPart& part)
    75 {
    76     switch (part) {
    77     case NoPart:
    78         return QStyle::SC_None;
    79     case BackButtonStartPart:
    80     case BackButtonEndPart:
    81         return QStyle::SC_ScrollBarSubLine;
    82     case BackTrackPart:
    83         return QStyle::SC_ScrollBarSubPage;
    84     case ThumbPart:
    85         return QStyle::SC_ScrollBarSlider;
    86     case ForwardTrackPart:
    87         return QStyle::SC_ScrollBarAddPage;
    88     case ForwardButtonStartPart:
    89     case ForwardButtonEndPart:
    90         return QStyle::SC_ScrollBarAddLine;
    91     }
    92 
    93     return QStyle::SC_None;
    94 }
    95 
    96 static ScrollbarPart scrollbarPart(const QStyle::SubControl& sc)
    97 {
    98     switch (sc) {
    99     case QStyle::SC_None:
    100         return NoPart;
    101     case QStyle::SC_ScrollBarSubLine:
    102         return BackButtonStartPart;
    103     case QStyle::SC_ScrollBarSubPage:
    104         return BackTrackPart;
    105     case QStyle::SC_ScrollBarSlider:
    106         return ThumbPart;
    107     case QStyle::SC_ScrollBarAddPage:
    108         return ForwardTrackPart;
    109     case QStyle::SC_ScrollBarAddLine:
    110         return ForwardButtonStartPart;
    111     }
    112     return NoPart;
    113 }
    114 
    115 static QStyleOptionSlider* styleOptionSlider(ScrollbarThemeClient* scrollbar, QWidget* widget = 0)
    116 {
    117     static QStyleOptionSlider opt;
    118     if (widget)
    119         opt.initFrom(widget);
    120     else
    121         opt.state |= QStyle::State_Active;
    122 
    123     opt.state &= ~QStyle::State_HasFocus;
    124 
    125     opt.rect = scrollbar->frameRect();
    126     if (scrollbar->enabled())
    127         opt.state |= QStyle::State_Enabled;
    128     if (scrollbar->controlSize() != RegularScrollbar)
    129         opt.state |= QStyle::State_Mini;
    130     opt.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;
    131 
    132     if (scrollbar->orientation() == HorizontalScrollbar)
    133         opt.state |= QStyle::State_Horizontal;
    134     else
    135         opt.state &= ~QStyle::State_Horizontal;
    136 
    137     opt.sliderValue = scrollbar->value();
    138     opt.sliderPosition = opt.sliderValue;
    139     opt.pageStep = scrollbar->pageStep();
    140     opt.singleStep = scrollbar->lineStep();
    141     opt.minimum = 0;
    142     opt.maximum = qMax(0, scrollbar->maximum());
    143     ScrollbarPart pressedPart = scrollbar->pressedPart();
    144     ScrollbarPart hoveredPart = scrollbar->hoveredPart();
    145     if (pressedPart != NoPart) {
    146         opt.activeSubControls = scPart(scrollbar->pressedPart());
    147         if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart
    148             || pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart
    149             || pressedPart == ThumbPart)
    150             opt.state |= QStyle::State_Sunken;
    151     } else
    152         opt.activeSubControls = scPart(hoveredPart);
    153     if (hoveredPart != NoPart)
    154         opt.state |= QStyle::State_MouseOver;
    155     return &opt;
    156 }
    157 
    158 bool ScrollbarThemeQt::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect)
    159 {
    160     if (graphicsContext->updatingControlTints()) {
    161        scrollbar->invalidateRect(damageRect);
    162        return false;
    163     }
    164 
    165     StylePainterQStyle p(this, graphicsContext);
    166     if (!p.isValid())
    167       return true;
    168 
    169     p.painter->save();
    170     QStyleOptionSlider* opt = styleOptionSlider(scrollbar, p.widget);
    171 
    172     p.painter->setClipRect(opt->rect.intersected(damageRect), Qt::IntersectClip);
    173 
    174 #ifdef Q_WS_MAC
    175     // FIXME: We also need to check the widget style but today ScrollbarTheme is not aware of the page so we
    176     // can't get the widget.
    177     if (qobject_cast<QMacStyle*>(style()))
    178         p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
    179     else
    180 #endif
    181     {
    182         // The QStyle expects the background to be already filled.
    183         p.painter->fillRect(opt->rect, opt->palette.background());
    184 
    185         const QPoint topLeft = opt->rect.topLeft();
    186         p.painter->translate(topLeft);
    187         opt->rect.moveTo(QPoint(0, 0));
    188         p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
    189         opt->rect.moveTo(topLeft);
    190     }
    191     p.painter->restore();
    192 
    193     return true;
    194 }
    195 
    196 ScrollbarPart ScrollbarThemeQt::hitTest(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt)
    197 {
    198     QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    199     const QPoint pos = scrollbar->convertFromContainingWindow(evt.position());
    200     opt->rect.moveTo(QPoint(0, 0));
    201     QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0);
    202     return scrollbarPart(sc);
    203 }
    204 
    205 bool ScrollbarThemeQt::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt)
    206 {
    207     // Middle click centers slider thumb (if supported).
    208     return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
    209 }
    210 
    211 void ScrollbarThemeQt::invalidatePart(ScrollbarThemeClient* scrollbar, ScrollbarPart)
    212 {
    213     // FIXME: Do more precise invalidation.
    214     scrollbar->invalidate();
    215 }
    216 
    217 int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize)
    218 {
    219     QStyleOptionSlider o;
    220     o.orientation = Qt::Vertical;
    221     o.state &= ~QStyle::State_Horizontal;
    222     if (controlSize != RegularScrollbar)
    223         o.state |= QStyle::State_Mini;
    224     return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
    225 }
    226 
    227 int ScrollbarThemeQt::thumbPosition(ScrollbarThemeClient* scrollbar)
    228 {
    229     if (scrollbar->enabled()) {
    230         float pos = (float)scrollbar->currentPos() * (trackLength(scrollbar) - thumbLength(scrollbar)) / scrollbar->maximum();
    231         return (pos < 1 && pos > 0) ? 1 : pos;
    232     }
    233     return 0;
    234 }
    235 
    236 int ScrollbarThemeQt::thumbLength(ScrollbarThemeClient* scrollbar)
    237 {
    238     QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    239     IntRect thumb = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0);
    240     return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height();
    241 }
    242 
    243 int ScrollbarThemeQt::trackPosition(ScrollbarThemeClient* scrollbar)
    244 {
    245     QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    246     IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
    247     return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y();
    248 }
    249 
    250 int ScrollbarThemeQt::trackLength(ScrollbarThemeClient* scrollbar)
    251 {
    252     QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    253     IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
    254     return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height();
    255 }
    256 
    257 void ScrollbarThemeQt::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& rect)
    258 {
    259     StylePainterQStyle p(this, context);
    260     if (!p.isValid())
    261         return;
    262 
    263     QStyleOption option;
    264     option.rect = rect;
    265     p.drawPrimitive(QStyle::PE_PanelScrollAreaCorner, option);
    266 }
    267 
    268 QStyle* ScrollbarThemeQt::style() const
    269 {
    270     return QApplication::style();
    271 }
    272 
    273 #endif // HAVE(QSTYLE)
    274 }
    275 
  • trunk/Source/WebKit/qt/Api/qwebpage.cpp

    r108643 r109542  
    32913291    d->page->contextMenuController()->clearContextMenu();
    32923292
    3293 #if HAVE(QSTYLE)
    3294     if (!RenderThemeQt::useMobileTheme()) {
    3295         if (QWebFrame* webFrame = frameAt(event->pos())) {
    3296             Frame* frame = QWebFramePrivate::core(webFrame);
    3297             if (Scrollbar* scrollbar = frame->view()->scrollbarAtPoint(convertMouseEvent(event, 1).position()))
    3298                 return handleScrollbarContextMenuEvent(scrollbar, event);
    3299         }
    3300     }
    3301 #endif
     3293    if (QWebFrame* webFrame = frameAt(event->pos())) {
     3294        Frame* frame = QWebFramePrivate::core(webFrame);
     3295        if (Scrollbar* scrollbar = frame->view()->scrollbarAtPoint(convertMouseEvent(event, 1).position()))
     3296            return handleScrollbarContextMenuEvent(scrollbar, event);
     3297    }
    33023298
    33033299    WebCore::Frame* focusedFrame = d->page->focusController()->focusedOrMainFrame();
  • trunk/Source/WebKit/qt/ChangeLog

    r109101 r109542  
     12012-03-02  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        [Qt] Move QStyle theming code out of WebCore into WebKit1
     4        https://bugs.webkit.org/show_bug.cgi?id=80128
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Moved the bulk of the QStyle dependant code here, where it's okay to depend on QtWidgets/QStyle.
     9        Install the QStyle factory functions in initWebCoreQt.cpp.
     10
     11        * Api/qwebpage.cpp:
     12        (QWebPage::swallowContextMenuEvent):
     13        * WebCoreSupport/InitWebCoreQt.cpp:
     14        (WebCore::initializeWebCoreQt):
     15        * WebCoreSupport/RenderThemeQStyle.cpp: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.cpp.
     16        (WebCore):
     17        (WebCore::initStyleOption):
     18        (WebCore::RenderThemeQStyle::getStylePainter):
     19        (WebCore::StylePainterQStyle::StylePainterQStyle):
     20        (WebCore::StylePainterQStyle::init):
     21        (WebCore::RenderThemeQStyle::create):
     22        (WebCore::RenderThemeQStyle::RenderThemeQStyle):
     23        (WebCore::RenderThemeQStyle::~RenderThemeQStyle):
     24        (WebCore::RenderThemeQStyle::fallbackStyle):
     25        (WebCore::RenderThemeQStyle::qStyle):
     26        (WebCore::RenderThemeQStyle::findFrameLineWidth):
     27        (WebCore::RenderThemeQStyle::inflateButtonRect):
     28        (WebCore::RenderThemeQStyle::computeSizeBasedOnStyle):
     29        (WebCore::RenderThemeQStyle::adjustButtonStyle):
     30        (WebCore::RenderThemeQStyle::setButtonPadding):
     31        (WebCore::RenderThemeQStyle::paintButton):
     32        (WebCore::RenderThemeQStyle::paintTextField):
     33        (WebCore::RenderThemeQStyle::adjustTextAreaStyle):
     34        (WebCore::RenderThemeQStyle::paintTextArea):
     35        (WebCore::RenderThemeQStyle::setPopupPadding):
     36        (WebCore::RenderThemeQStyle::paintMenuList):
     37        (WebCore::RenderThemeQStyle::adjustMenuListButtonStyle):
     38        (WebCore::RenderThemeQStyle::paintMenuListButton):
     39        (WebCore::RenderThemeQStyle::animationDurationForProgressBar):
     40        (WebCore::RenderThemeQStyle::paintProgressBar):
     41        (WebCore::RenderThemeQStyle::paintSliderTrack):
     42        (WebCore::RenderThemeQStyle::adjustSliderTrackStyle):
     43        (WebCore::RenderThemeQStyle::paintSliderThumb):
     44        (WebCore::RenderThemeQStyle::adjustSliderThumbStyle):
     45        (WebCore::RenderThemeQStyle::paintSearchField):
     46        (WebCore::RenderThemeQStyle::adjustSearchFieldDecorationStyle):
     47        (WebCore::RenderThemeQStyle::paintSearchFieldDecoration):
     48        (WebCore::RenderThemeQStyle::adjustSearchFieldResultsDecorationStyle):
     49        (WebCore::RenderThemeQStyle::paintSearchFieldResultsDecoration):
     50        (WebCore::RenderThemeQStyle::paintInnerSpinButton):
     51        (WebCore::RenderThemeQStyle::initializeCommonQStyleOptions):
     52        (WebCore::RenderThemeQStyle::adjustSliderThumbSize):
     53        * WebCoreSupport/RenderThemeQStyle.h: Renamed from Source/WebCore/platform/qt/RenderThemeQStyle.h.
     54        (WebCore):
     55        (RenderThemeQStyle):
     56        (StylePainterQStyle):
     57        (WebCore::StylePainterQStyle::isValid):
     58        (WebCore::StylePainterQStyle::drawPrimitive):
     59        (WebCore::StylePainterQStyle::drawControl):
     60        (WebCore::StylePainterQStyle::drawComplexControl):
     61        * WebCoreSupport/ScrollbarThemeQStyle.cpp: Copied from Source/WebCore/platform/qt/ScrollbarThemeQt.cpp.
     62        (WebCore):
     63        (WebCore::ScrollbarThemeQStyle::~ScrollbarThemeQStyle):
     64        (WebCore::scPart):
     65        (WebCore::scrollbarPart):
     66        (WebCore::styleOptionSlider):
     67        (WebCore::ScrollbarThemeQStyle::paint):
     68        (WebCore::ScrollbarThemeQStyle::hitTest):
     69        (WebCore::ScrollbarThemeQStyle::shouldCenterOnThumb):
     70        (WebCore::ScrollbarThemeQStyle::invalidatePart):
     71        (WebCore::ScrollbarThemeQStyle::scrollbarThickness):
     72        (WebCore::ScrollbarThemeQStyle::thumbPosition):
     73        (WebCore::ScrollbarThemeQStyle::thumbLength):
     74        (WebCore::ScrollbarThemeQStyle::trackPosition):
     75        (WebCore::ScrollbarThemeQStyle::trackLength):
     76        (WebCore::ScrollbarThemeQStyle::paintScrollCorner):
     77        (WebCore::ScrollbarThemeQStyle::style):
     78        * WebCoreSupport/ScrollbarThemeQStyle.h: Renamed from Source/WebCore/platform/qt/ScrollbarThemeQt.h.
     79        (WebCore):
     80        (ScrollbarThemeQStyle):
     81
    1822012-02-27  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
    283
  • trunk/Source/WebKit/qt/WebCoreSupport/InitWebCoreQt.cpp

    r107811 r109542  
    3434#include "NotImplemented.h"
    3535#include "PlatformStrategiesQt.h"
     36#include "RenderThemeQStyle.h"
    3637#include "ScriptController.h"
     38#include "ScrollbarThemeQStyle.h"
    3739#include "SecurityPolicy.h"
    3840#if USE(QTKIT)
     
    6365    QtWebElementRuntime::initialize();
    6466
     67    RenderThemeQt::setCustomTheme(RenderThemeQStyle::create, new ScrollbarThemeQStyle);
     68
    6569#if USE(QTKIT)
    6670    InitWebCoreSystemInterface();
  • trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp

    r109541 r109542  
    22 * This file is part of the WebKit project.
    33 *
    4  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     4 * Copyright (C) 2008-2012 Nokia Corporation and/or its subsidiary(-ies)
    55 *
    66 * Copyright (C) 2006 Zack Rusin <zack@kde.org>
     
    5353#endif
    5454#include "RenderSlider.h"
    55 #include "ScrollbarThemeQt.h"
     55#include "ScrollbarThemeQStyle.h"
    5656#include "SliderThumbElement.h"
    5757#include "UserAgentStyleSheets.h"
     
    8181using namespace HTMLNames;
    8282
    83 inline static void initStyleOption(QWidget *widget, QStyleOption& option)
     83inline static void initStyleOption(QWidget* widget, QStyleOption& option)
    8484{
    8585    if (widget)
    8686        option.initFrom(widget);
    8787    else {
    88         /*
    89           If a widget is not directly available for rendering, we fallback to default
    90           value for an active widget.
    91          */
     88        // If a widget is not directly available for rendering, we fallback to default
     89        // value for an active widget.
    9290        option.state = QStyle::State_Active | QStyle::State_Enabled;
    9391    }
     
    106104}
    107105
    108 StylePainterQStyle::StylePainterQStyle(ScrollbarThemeQt* theme, GraphicsContext* context)
     106StylePainterQStyle::StylePainterQStyle(ScrollbarThemeQStyle* theme, GraphicsContext* context)
    109107    : StylePainter()
    110108{
  • trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h

    r109541 r109542  
    22 * This file is part of the theme implementation for form controls in WebCore.
    33 *
    4  * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
     4 * Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies).
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    3737namespace WebCore {
    3838
    39 class ScrollbarThemeQt;
     39class ScrollbarThemeQStyle;
    4040
    4141class RenderThemeQStyle : public RenderThemeQt {
     
    120120public:
    121121    explicit StylePainterQStyle(RenderThemeQStyle*, const PaintInfo&);
    122     explicit StylePainterQStyle(ScrollbarThemeQt*, GraphicsContext*);
     122    explicit StylePainterQStyle(ScrollbarThemeQStyle*, GraphicsContext*);
    123123
    124124    bool isValid() const { return style && StylePainter::isValid(); }
  • trunk/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.cpp

    r109541 r109542  
    2727
    2828#include "config.h"
    29 
    30 #if !HAVE(QSTYLE)
    31 #include "ScrollbarTheme.h"
    32 
    33 #else
    34 #include "ScrollbarThemeQt.h"
     29#include "ScrollbarThemeQStyle.h"
    3530
    3631#include "GraphicsContext.h"
     
    4944#include <QStyle>
    5045#include <QStyleOptionSlider>
    51 #endif // HAVE(QSTYLE)
    5246
    5347namespace WebCore {
    5448
    55 ScrollbarTheme* ScrollbarTheme::nativeTheme()
    56 {
    57     static ScrollbarTheme* theme = 0;
    58     if (theme)
    59         return theme;
    60 #if HAVE(QSTYLE)
    61     if (!RenderThemeQt::useMobileTheme())
    62         theme = new ScrollbarThemeQt();
    63     else
    64 #endif
    65         theme = new ScrollbarTheme();
    66     return theme;
    67 }
    68 
    69 #if HAVE(QSTYLE)
    70 ScrollbarThemeQt::~ScrollbarThemeQt()
     49ScrollbarThemeQStyle::~ScrollbarThemeQStyle()
    7150{
    7251}
     
    156135}
    157136
    158 bool ScrollbarThemeQt::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect)
     137bool ScrollbarThemeQStyle::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& dirtyRect)
    159138{
    160139    if (graphicsContext->updatingControlTints()) {
    161        scrollbar->invalidateRect(damageRect);
     140       scrollbar->invalidateRect(dirtyRect);
    162141       return false;
    163142    }
     
    170149    QStyleOptionSlider* opt = styleOptionSlider(scrollbar, p.widget);
    171150
    172     p.painter->setClipRect(opt->rect.intersected(damageRect), Qt::IntersectClip);
     151    p.painter->setClipRect(opt->rect.intersected(dirtyRect), Qt::IntersectClip);
    173152
    174153#ifdef Q_WS_MAC
     
    194173}
    195174
    196 ScrollbarPart ScrollbarThemeQt::hitTest(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt)
     175ScrollbarPart ScrollbarThemeQStyle::hitTest(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt)
    197176{
    198177    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
     
    203182}
    204183
    205 bool ScrollbarThemeQt::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt)
     184bool ScrollbarThemeQStyle::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt)
    206185{
    207186    // Middle click centers slider thumb (if supported).
     
    209188}
    210189
    211 void ScrollbarThemeQt::invalidatePart(ScrollbarThemeClient* scrollbar, ScrollbarPart)
     190void ScrollbarThemeQStyle::invalidatePart(ScrollbarThemeClient* scrollbar, ScrollbarPart)
    212191{
    213192    // FIXME: Do more precise invalidation.
     
    215194}
    216195
    217 int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize)
     196int ScrollbarThemeQStyle::scrollbarThickness(ScrollbarControlSize controlSize)
    218197{
    219198    QStyleOptionSlider o;
     
    225204}
    226205
    227 int ScrollbarThemeQt::thumbPosition(ScrollbarThemeClient* scrollbar)
     206int ScrollbarThemeQStyle::thumbPosition(ScrollbarThemeClient* scrollbar)
    228207{
    229208    if (scrollbar->enabled()) {
     
    234213}
    235214
    236 int ScrollbarThemeQt::thumbLength(ScrollbarThemeClient* scrollbar)
     215int ScrollbarThemeQStyle::thumbLength(ScrollbarThemeClient* scrollbar)
    237216{
    238217    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
     
    241220}
    242221
    243 int ScrollbarThemeQt::trackPosition(ScrollbarThemeClient* scrollbar)
     222int ScrollbarThemeQStyle::trackPosition(ScrollbarThemeClient* scrollbar)
    244223{
    245224    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
     
    248227}
    249228
    250 int ScrollbarThemeQt::trackLength(ScrollbarThemeClient* scrollbar)
     229int ScrollbarThemeQStyle::trackLength(ScrollbarThemeClient* scrollbar)
    251230{
    252231    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
     
    255234}
    256235
    257 void ScrollbarThemeQt::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& rect)
     236void ScrollbarThemeQStyle::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& rect)
    258237{
    259238    StylePainterQStyle p(this, context);
     
    266245}
    267246
    268 QStyle* ScrollbarThemeQt::style() const
     247QStyle* ScrollbarThemeQStyle::style() const
    269248{
    270249    return QApplication::style();
    271250}
    272251
    273 #endif // HAVE(QSTYLE)
    274 }
    275 
     252}
     253
  • trunk/Source/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.h

    r109541 r109542  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
    26 #ifndef ScrollbarThemeQt_h
    27 #define ScrollbarThemeQt_h
     26#ifndef ScrollbarThemeQStyle_h
     27#define ScrollbarThemeQStyle_h
    2828
    2929#include "ScrollbarTheme.h"
     
    3737namespace WebCore {
    3838
    39 class ScrollbarThemeQt : public ScrollbarTheme {
     39class ScrollbarThemeQStyle : public ScrollbarTheme {
    4040public:
    41     virtual ~ScrollbarThemeQt();
     41    virtual ~ScrollbarThemeQStyle();
    4242
    43     virtual bool paint(ScrollbarThemeClient*, GraphicsContext*, const IntRect& damageRect);
     43    virtual bool paint(ScrollbarThemeClient*, GraphicsContext*, const IntRect& dirtyRect);
    4444    virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect);
    4545
  • trunk/Source/api.pri

    r107915 r109542  
    6060    $$PWD/WebKit/qt/WebCoreSupport/PopupMenuQt.cpp \
    6161    $$PWD/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp \
     62    $$PWD/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp \
     63    $$PWD/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.cpp \
    6264    $$PWD/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.cpp \
    6365    $$PWD/WebKit/qt/WebCoreSupport/TextCheckerClientQt.cpp \
     
    7577    $$PWD/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h \
    7678    $$PWD/WebKit/qt/WebCoreSupport/PageClientQt.h \
     79    $$PWD/WebKit/qt/WebCoreSupport/PopupMenuQt.h \
    7780    $$PWD/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h \
    78     $$PWD/WebKit/qt/WebCoreSupport/PopupMenuQt.h \
     81    $$PWD/WebKit/qt/WebCoreSupport/QtStyleOptionWebComboBox.h.h \
     82    $$PWD/WebKit/qt/WebCoreSupport/RenderThemeQStyle.h \
     83    $$PWD/WebKit/qt/WebCoreSupport/ScrollbarThemeQStyle.h \
    7984    $$PWD/WebKit/qt/WebCoreSupport/SearchPopupMenuQt.h \
    8085    $$PWD/WebKit/qt/WebCoreSupport/TextCheckerClientQt.h \
Note: See TracChangeset for help on using the changeset viewer.