Changeset 53803 in webkit


Ignore:
Timestamp:
Jan 25, 2010 7:08:24 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-25 Simon Hausmann <Simon Hausmann>

Reviewed by Kenneth Rohde Christiansen.

[Qt] In the StyledPainter determine the style from the Render and Scrollbar theme instead of from the paint device
https://bugs.webkit.org/show_bug.cgi?id=34054

Getting the style from the painter's paint device is a hack that breaks when
the paint device's style is different than the style that is used when
calculating the metries earlier when there is no painter available.

This change moves us closer to always using the same style.

  • platform/qt/RenderThemeQt.cpp: (WebCore::StylePainter::StylePainter): (WebCore::StylePainter::init): (WebCore::RenderThemeQt::paintButton): (WebCore::RenderThemeQt::paintTextField): (WebCore::RenderThemeQt::paintMenuList): (WebCore::RenderThemeQt::paintMenuListButton): (WebCore::RenderThemeQt::paintSliderTrack): (WebCore::RenderThemeQt::paintMediaMuteButton): (WebCore::RenderThemeQt::paintMediaPlayButton): (WebCore::RenderThemeQt::paintMediaSliderTrack): (WebCore::RenderThemeQt::paintMediaSliderThumb):
  • platform/qt/RenderThemeQt.h:
  • platform/qt/ScrollbarThemeQt.cpp: (WebCore::ScrollbarThemeQt::paint): (WebCore::ScrollbarThemeQt::hitTest): (WebCore::ScrollbarThemeQt::shouldCenterOnThumb): (WebCore::ScrollbarThemeQt::scrollbarThickness): (WebCore::ScrollbarThemeQt::thumbLength): (WebCore::ScrollbarThemeQt::trackPosition): (WebCore::ScrollbarThemeQt::trackLength): (WebCore::ScrollbarThemeQt::paintScrollCorner): (WebCore::ScrollbarThemeQt::style):
  • platform/qt/ScrollbarThemeQt.h:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53802 r53803  
     12010-01-25  Simon Hausmann  <hausmann@webkit.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] In the StyledPainter determine the style from the Render and Scrollbar theme instead of from the paint device
     6        https://bugs.webkit.org/show_bug.cgi?id=34054
     7
     8        Getting the style from the painter's paint device is a hack that breaks when
     9        the paint device's style is different than the style that is used when
     10        calculating the metries earlier when there is no painter available.
     11
     12        This change moves us closer to always using the same style.
     13
     14        * platform/qt/RenderThemeQt.cpp:
     15        (WebCore::StylePainter::StylePainter):
     16        (WebCore::StylePainter::init):
     17        (WebCore::RenderThemeQt::paintButton):
     18        (WebCore::RenderThemeQt::paintTextField):
     19        (WebCore::RenderThemeQt::paintMenuList):
     20        (WebCore::RenderThemeQt::paintMenuListButton):
     21        (WebCore::RenderThemeQt::paintSliderTrack):
     22        (WebCore::RenderThemeQt::paintMediaMuteButton):
     23        (WebCore::RenderThemeQt::paintMediaPlayButton):
     24        (WebCore::RenderThemeQt::paintMediaSliderTrack):
     25        (WebCore::RenderThemeQt::paintMediaSliderThumb):
     26        * platform/qt/RenderThemeQt.h:
     27        * platform/qt/ScrollbarThemeQt.cpp:
     28        (WebCore::ScrollbarThemeQt::paint):
     29        (WebCore::ScrollbarThemeQt::hitTest):
     30        (WebCore::ScrollbarThemeQt::shouldCenterOnThumb):
     31        (WebCore::ScrollbarThemeQt::scrollbarThickness):
     32        (WebCore::ScrollbarThemeQt::thumbLength):
     33        (WebCore::ScrollbarThemeQt::trackPosition):
     34        (WebCore::ScrollbarThemeQt::trackLength):
     35        (WebCore::ScrollbarThemeQt::paintScrollCorner):
     36        (WebCore::ScrollbarThemeQt::style):
     37        * platform/qt/ScrollbarThemeQt.h:
     38
    1392010-01-25  Simon Hausmann  <hausmann@webkit.org>
    240
  • trunk/WebCore/platform/qt/RenderThemeQt.cpp

    r53802 r53803  
    4848#include "RenderSlider.h"
    4949#include "RenderTheme.h"
     50#include "ScrollbarThemeQt.h"
    5051#include "UserAgentStyleSheets.h"
    5152#include "qwebpage.h"
     
    7071
    7172
    72 StylePainter::StylePainter(const RenderObject::PaintInfo& paintInfo)
    73 {
    74     init(paintInfo.context ? paintInfo.context : 0);
    75 }
    76 
    77 StylePainter::StylePainter(GraphicsContext* context)
    78 {
    79     init(context);
    80 }
    81 
    82 void StylePainter::init(GraphicsContext* context)
     73StylePainter::StylePainter(RenderThemeQt* theme, const RenderObject::PaintInfo& paintInfo)
     74{
     75    init(paintInfo.context ? paintInfo.context : 0, theme->qStyle());
     76}
     77
     78StylePainter::StylePainter(ScrollbarThemeQt* theme, GraphicsContext* context)
     79{
     80    init(context, theme->style());
     81}
     82
     83void StylePainter::init(GraphicsContext* context, QStyle* themeStyle)
    8384{
    8485    painter = static_cast<QPainter*>(context->platformContext());
     
    8990    if (dev && dev->devType() == QInternal::Widget)
    9091        widget = static_cast<QWidget*>(dev);
    91     style = (widget ? widget->style() : QApplication::style());
     92    style = themeStyle;
    9293
    9394    if (painter) {
     
    466467bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    467468{
    468     StylePainter p(i);
     469    StylePainter p(this, i);
    469470    if (!p.isValid())
    470471       return true;
     
    499500bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    500501{
    501     StylePainter p(i);
     502    StylePainter p(this, i);
    502503    if (!p.isValid())
    503504        return true;
     
    568569bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
    569570{
    570     StylePainter p(i);
     571    StylePainter p(this, i);
    571572    if (!p.isValid())
    572573        return true;
     
    608609                                        const IntRect& r)
    609610{
    610     StylePainter p(i);
     611    StylePainter p(this, i);
    611612    if (!p.isValid())
    612613        return true;
     
    629630                                     const IntRect& r)
    630631{
    631     StylePainter p(pi);
     632    StylePainter p(this, pi);
    632633    if (!p.isValid())
    633634       return true;
     
    900901        return false;
    901902
    902     StylePainter p(paintInfo);
     903    StylePainter p(this, paintInfo);
    903904    if (!p.isValid())
    904905        return true;
     
    929930        return false;
    930931
    931     StylePainter p(paintInfo);
     932    StylePainter p(this, paintInfo);
    932933    if (!p.isValid())
    933934        return true;
     
    968969        return false;
    969970
    970     StylePainter p(paintInfo);
     971    StylePainter p(this, paintInfo);
    971972    if (!p.isValid())
    972973        return true;
     
    985986        return false;
    986987
    987     StylePainter p(paintInfo);
     988    StylePainter p(this, paintInfo);
    988989    if (!p.isValid())
    989990        return true;
  • trunk/WebCore/platform/qt/RenderThemeQt.h

    r53801 r53803  
    3636class RenderStyle;
    3737class HTMLMediaElement;
     38class ScrollbarThemeQt;
    3839
    3940class RenderThemeQt : public RenderTheme {
     
    7576    virtual String extraMediaControlsStyleSheet();
    7677#endif
     78
     79    QStyle* qStyle() const;
    7780
    7881protected:
     
    143146    void setPaletteFromPageClientIfExists(QPalette&) const;
    144147
    145     QStyle* qStyle() const;
    146148    QStyle* fallbackStyle();
    147149
     
    158160class StylePainter {
    159161public:
    160     explicit StylePainter(const RenderObject::PaintInfo& paintInfo);
    161     explicit StylePainter(GraphicsContext* context);
     162    explicit StylePainter(RenderThemeQt*, const RenderObject::PaintInfo&);
     163    explicit StylePainter(ScrollbarThemeQt*, GraphicsContext*);
    162164    ~StylePainter();
    163165
     
    176178
    177179private:
    178     void init(GraphicsContext* context);
     180    void init(GraphicsContext* context, QStyle*);
    179181
    180182    QBrush oldBrush;
  • trunk/WebCore/platform/qt/ScrollbarThemeQt.cpp

    r52601 r53803  
    141141    }
    142142
    143     StylePainter p(graphicsContext);
     143    StylePainter p(this, graphicsContext);
    144144    if (!p.isValid())
    145145      return true;
     
    173173    const QPoint pos = scrollbar->convertFromContainingWindow(evt.pos());
    174174    opt->rect.moveTo(QPoint(0, 0));
    175     QStyle::SubControl sc = QApplication::style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0);
     175    QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0);
    176176    return scrollbarPart(sc);
    177177}
     
    180180{
    181181    // Middle click centers slider thumb (if supported)
    182     return QApplication::style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
     182    return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
    183183}
    184184
     
    191191int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize)
    192192{
    193     QStyle* s = QApplication::style();
    194193    QStyleOptionSlider o;
    195194    o.orientation = Qt::Vertical;
     
    197196    if (controlSize != RegularScrollbar)
    198197        o.state |= QStyle::State_Mini;
    199     return s->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
     198    return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
    200199}
    201200
     
    210209{
    211210    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    212     IntRect thumb = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0);
     211    IntRect thumb = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0);
    213212    return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height();
    214213}
     
    217216{
    218217    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    219     IntRect track = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
     218    IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
    220219    return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y();
    221220}
     
    224223{
    225224    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    226     IntRect track = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
     225    IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
    227226    return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height();
    228227}
     
    238237    context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window), DeviceColorSpace);
    239238#else
    240     StylePainter p(context);
     239    StylePainter p(this, context);
    241240    if (!p.isValid())
    242241        return;
     
    248247}
    249248
    250 }
    251 
     249QStyle* ScrollbarThemeQt::style() const
     250{
     251    return QApplication::style();
     252}
     253
     254}
     255
  • trunk/WebCore/platform/qt/ScrollbarThemeQt.h

    r46170 r53803  
    2929#include "ScrollbarTheme.h"
    3030
     31#include <QtCore/qglobal.h>
     32
     33QT_BEGIN_NAMESPACE
     34class QStyle;
     35QT_END_NAMESPACE
     36
    3137namespace WebCore {
    3238
     
    5056
    5157    virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
     58
     59    QStyle* style() const;
    5260};
    5361
Note: See TracChangeset for help on using the changeset viewer.