Changeset 52664 in webkit
- Timestamp:
- Dec 30, 2009 9:42:05 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52663 r52664 1 2009-12-30 Carol Szabo <carol.szabo@nokia.com> 2 3 Reviewed by Laszlo Gombos. 4 5 [Qt] RenderThemeQt::applyTheme is a misnomer and is suboptimally coded. 6 https://bugs.webkit.org/show_bug.cgi?id=33035 7 8 This patch: 9 - renames RenderThemeQt::applyTheme to initializeCommonQStyleOptions, 10 - extracts the palette initialization code to a separate function in order to 11 provide for readable pointer checking and moves this code up in the function to 12 allow for future changes to the palette brushes needed for bug 30173, 13 - optimizes some of the code in the function for readability, speed and size. 14 - fixes some minor style issues 15 16 No new tests because code behavior is not changed. 17 18 * platform/qt/RenderThemeQt.cpp: 19 (WebCore::RenderThemeQt::paintButton): 20 (WebCore::RenderThemeQt::paintTextField): 21 (WebCore::RenderThemeQt::paintMenuList): 22 (WebCore::RenderThemeQt::paintMenuListButton): 23 (WebCore::initPaletteFromPageClientIfExists): 24 (WebCore::RenderThemeQt::initializeCommonQStyleOptions): 25 * platform/qt/RenderThemeQt.h: 26 1 27 2009-12-30 Laszlo Gombos <laszlo.1.gombos@nokia.com> 2 28 -
trunk/WebCore/platform/qt/RenderThemeQt.cpp
r52518 r52664 44 44 #include "NotImplemented.h" 45 45 #include "Page.h" 46 #include "QWebPageClient.h" 46 47 #include "RenderBox.h" 47 48 #include "RenderTheme.h" 48 49 #include "UserAgentStyleSheets.h" 49 #include "QWebPageClient.h"50 50 #include "qwebpage.h" 51 51 … … 478 478 option.state |= QStyle::State_Small; 479 479 480 ControlPart appearance = applyTheme(option, o);480 ControlPart appearance = initializeCommonQStyleOptions(option, o); 481 481 if (appearance == PushButtonPart || appearance == ButtonPart) { 482 482 option.rect = inflateButtonRect(option.rect, qStyle()); … … 514 514 515 515 // Get the correct theme data for a text field 516 ControlPart appearance = applyTheme(panel, o);516 ControlPart appearance = initializeCommonQStyleOptions(panel, o); 517 517 if (appearance != TextFieldPart 518 518 && appearance != SearchFieldPart … … 576 576 if (p.widget) 577 577 opt.initFrom(p.widget); 578 applyTheme(opt, o);578 initializeCommonQStyleOptions(opt, o); 579 579 580 580 const QPoint topLeft = r.topLeft(); … … 616 616 if (p.widget) 617 617 option.initFrom(p.widget); 618 applyTheme(option, o);618 initializeCommonQStyleOptions(option, o); 619 619 option.rect = r; 620 620 … … 713 713 } 714 714 715 ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const 715 static inline void setPaletteFromPageClientIfExists(QPalette &palette, const RenderObject *o) 716 { 717 // If the webview has a custom palette, use it 718 Page* page = o->document()->page(); 719 if (!page) 720 return; 721 Chrome* chrome = page->chrome(); 722 if (!chrome) 723 return; 724 ChromeClient* chromeClient = chrome->client(); 725 if (!chromeClient) 726 return; 727 QWebPageClient* pageClient = chromeClient->platformPageClient(); 728 if (!pageClient) 729 return; 730 palette = pageClient->palette(); 731 } 732 733 ControlPart RenderThemeQt::initializeCommonQStyleOptions(QStyleOption& option, RenderObject* o) const 716 734 { 717 735 // Default bits: no focus, no mouse over … … 725 743 option.state |= QStyle::State_ReadOnly; 726 744 727 if (supportsFocus(o->style()->appearance()) && isFocused(o)) { 745 option.direction = Qt::LeftToRight; 746 747 if (isHovered(o)) 748 option.state |= QStyle::State_MouseOver; 749 750 setPaletteFromPageClientIfExists(option.palette, o); 751 RenderStyle* style = o->style(); 752 if (!style) 753 return NoControlPart; 754 755 ControlPart result = style->appearance(); 756 if (supportsFocus(result) && isFocused(o)) { 728 757 option.state |= QStyle::State_HasFocus; 729 758 option.state |= QStyle::State_KeyboardFocusChange; 730 759 } 731 760 732 if (isHovered(o)) 733 option.state |= QStyle::State_MouseOver; 734 735 option.direction = Qt::LeftToRight; 736 if (o->style() && o->style()->direction() == WebCore::RTL) 761 if (style->direction() == WebCore::RTL) 737 762 option.direction = Qt::RightToLeft; 738 739 ControlPart result = o->style()->appearance();740 763 741 764 switch (result) { … … 754 777 break; 755 778 } 756 } 757 758 if (result == RadioPart || result == CheckboxPart) 779 case RadioPart: 780 case CheckboxPart: 759 781 option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off); 760 761 // If the owner widget has a custom palette, use it762 Page* page = o->document()->page();763 if (page) {764 ChromeClient* client = page->chrome()->client();765 QWebPageClient* pageClient = client->platformPageClient();766 if (pageClient)767 option.palette = pageClient->palette();768 782 } 769 783 -
trunk/WebCore/platform/qt/RenderThemeQt.h
r46170 r52664 20 20 * 21 21 */ 22 #ifndef RenderThemeQt_ H23 #define RenderThemeQt_ H22 #ifndef RenderThemeQt_h 23 #define RenderThemeQt_h 24 24 25 25 #include "RenderTheme.h" … … 133 133 bool supportsFocus(ControlPart) const; 134 134 135 ControlPart applyTheme(QStyleOption&, RenderObject*) const;135 ControlPart initializeCommonQStyleOptions(QStyleOption&, RenderObject*) const; 136 136 137 137 void setButtonPadding(RenderStyle*) const; … … 181 181 } 182 182 183 #endif 183 #endif // RenderThemeQt_h
Note: See TracChangeset
for help on using the changeset viewer.