Changeset 53803 in webkit
- Timestamp:
- Jan 25, 2010 7:08:24 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r53802 r53803 1 2010-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 1 39 2010-01-25 Simon Hausmann <hausmann@webkit.org> 2 40 -
trunk/WebCore/platform/qt/RenderThemeQt.cpp
r53802 r53803 48 48 #include "RenderSlider.h" 49 49 #include "RenderTheme.h" 50 #include "ScrollbarThemeQt.h" 50 51 #include "UserAgentStyleSheets.h" 51 52 #include "qwebpage.h" … … 70 71 71 72 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 )73 StylePainter::StylePainter(RenderThemeQt* theme, const RenderObject::PaintInfo& paintInfo) 74 { 75 init(paintInfo.context ? paintInfo.context : 0, theme->qStyle()); 76 } 77 78 StylePainter::StylePainter(ScrollbarThemeQt* theme, GraphicsContext* context) 79 { 80 init(context, theme->style()); 81 } 82 83 void StylePainter::init(GraphicsContext* context, QStyle* themeStyle) 83 84 { 84 85 painter = static_cast<QPainter*>(context->platformContext()); … … 89 90 if (dev && dev->devType() == QInternal::Widget) 90 91 widget = static_cast<QWidget*>(dev); 91 style = (widget ? widget->style() : QApplication::style());92 style = themeStyle; 92 93 93 94 if (painter) { … … 466 467 bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) 467 468 { 468 StylePainter p( i);469 StylePainter p(this, i); 469 470 if (!p.isValid()) 470 471 return true; … … 499 500 bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) 500 501 { 501 StylePainter p( i);502 StylePainter p(this, i); 502 503 if (!p.isValid()) 503 504 return true; … … 568 569 bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) 569 570 { 570 StylePainter p( i);571 StylePainter p(this, i); 571 572 if (!p.isValid()) 572 573 return true; … … 608 609 const IntRect& r) 609 610 { 610 StylePainter p( i);611 StylePainter p(this, i); 611 612 if (!p.isValid()) 612 613 return true; … … 629 630 const IntRect& r) 630 631 { 631 StylePainter p( pi);632 StylePainter p(this, pi); 632 633 if (!p.isValid()) 633 634 return true; … … 900 901 return false; 901 902 902 StylePainter p( paintInfo);903 StylePainter p(this, paintInfo); 903 904 if (!p.isValid()) 904 905 return true; … … 929 930 return false; 930 931 931 StylePainter p( paintInfo);932 StylePainter p(this, paintInfo); 932 933 if (!p.isValid()) 933 934 return true; … … 968 969 return false; 969 970 970 StylePainter p( paintInfo);971 StylePainter p(this, paintInfo); 971 972 if (!p.isValid()) 972 973 return true; … … 985 986 return false; 986 987 987 StylePainter p( paintInfo);988 StylePainter p(this, paintInfo); 988 989 if (!p.isValid()) 989 990 return true; -
trunk/WebCore/platform/qt/RenderThemeQt.h
r53801 r53803 36 36 class RenderStyle; 37 37 class HTMLMediaElement; 38 class ScrollbarThemeQt; 38 39 39 40 class RenderThemeQt : public RenderTheme { … … 75 76 virtual String extraMediaControlsStyleSheet(); 76 77 #endif 78 79 QStyle* qStyle() const; 77 80 78 81 protected: … … 143 146 void setPaletteFromPageClientIfExists(QPalette&) const; 144 147 145 QStyle* qStyle() const;146 148 QStyle* fallbackStyle(); 147 149 … … 158 160 class StylePainter { 159 161 public: 160 explicit StylePainter( const RenderObject::PaintInfo& paintInfo);161 explicit StylePainter( GraphicsContext* context);162 explicit StylePainter(RenderThemeQt*, const RenderObject::PaintInfo&); 163 explicit StylePainter(ScrollbarThemeQt*, GraphicsContext*); 162 164 ~StylePainter(); 163 165 … … 176 178 177 179 private: 178 void init(GraphicsContext* context );180 void init(GraphicsContext* context, QStyle*); 179 181 180 182 QBrush oldBrush; -
trunk/WebCore/platform/qt/ScrollbarThemeQt.cpp
r52601 r53803 141 141 } 142 142 143 StylePainter p( graphicsContext);143 StylePainter p(this, graphicsContext); 144 144 if (!p.isValid()) 145 145 return true; … … 173 173 const QPoint pos = scrollbar->convertFromContainingWindow(evt.pos()); 174 174 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); 176 176 return scrollbarPart(sc); 177 177 } … … 180 180 { 181 181 // 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; 183 183 } 184 184 … … 191 191 int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize) 192 192 { 193 QStyle* s = QApplication::style();194 193 QStyleOptionSlider o; 195 194 o.orientation = Qt::Vertical; … … 197 196 if (controlSize != RegularScrollbar) 198 197 o.state |= QStyle::State_Mini; 199 return s ->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);198 return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0); 200 199 } 201 200 … … 210 209 { 211 210 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); 213 212 return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height(); 214 213 } … … 217 216 { 218 217 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); 220 219 return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y(); 221 220 } … … 224 223 { 225 224 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); 227 226 return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height(); 228 227 } … … 238 237 context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window), DeviceColorSpace); 239 238 #else 240 StylePainter p( context);239 StylePainter p(this, context); 241 240 if (!p.isValid()) 242 241 return; … … 248 247 } 249 248 250 } 251 249 QStyle* ScrollbarThemeQt::style() const 250 { 251 return QApplication::style(); 252 } 253 254 } 255 -
trunk/WebCore/platform/qt/ScrollbarThemeQt.h
r46170 r53803 29 29 #include "ScrollbarTheme.h" 30 30 31 #include <QtCore/qglobal.h> 32 33 QT_BEGIN_NAMESPACE 34 class QStyle; 35 QT_END_NAMESPACE 36 31 37 namespace WebCore { 32 38 … … 50 56 51 57 virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar); 58 59 QStyle* style() const; 52 60 }; 53 61
Note: See TracChangeset
for help on using the changeset viewer.