[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
eric at webkit.org
eric at webkit.org
Thu Apr 8 00:52:22 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit c88cf4a899a6c3e321e0540f1f05bf72a7b254c4
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Dec 30 17:42:05 2009 +0000
2009-12-30 Carol Szabo <carol.szabo at nokia.com>
Reviewed by Laszlo Gombos.
[Qt] RenderThemeQt::applyTheme is a misnomer and is suboptimally coded.
https://bugs.webkit.org/show_bug.cgi?id=33035
This patch:
- renames RenderThemeQt::applyTheme to initializeCommonQStyleOptions,
- extracts the palette initialization code to a separate function in order to
provide for readable pointer checking and moves this code up in the function to
allow for future changes to the palette brushes needed for bug 30173,
- optimizes some of the code in the function for readability, speed and size.
- fixes some minor style issues
No new tests because code behavior is not changed.
* platform/qt/RenderThemeQt.cpp:
(WebCore::RenderThemeQt::paintButton):
(WebCore::RenderThemeQt::paintTextField):
(WebCore::RenderThemeQt::paintMenuList):
(WebCore::RenderThemeQt::paintMenuListButton):
(WebCore::initPaletteFromPageClientIfExists):
(WebCore::RenderThemeQt::initializeCommonQStyleOptions):
* platform/qt/RenderThemeQt.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index eab23ab..4320170 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2009-12-30 Carol Szabo <carol.szabo at nokia.com>
+
+ Reviewed by Laszlo Gombos.
+
+ [Qt] RenderThemeQt::applyTheme is a misnomer and is suboptimally coded.
+ https://bugs.webkit.org/show_bug.cgi?id=33035
+
+ This patch:
+ - renames RenderThemeQt::applyTheme to initializeCommonQStyleOptions,
+ - extracts the palette initialization code to a separate function in order to
+ provide for readable pointer checking and moves this code up in the function to
+ allow for future changes to the palette brushes needed for bug 30173,
+ - optimizes some of the code in the function for readability, speed and size.
+ - fixes some minor style issues
+
+ No new tests because code behavior is not changed.
+
+ * platform/qt/RenderThemeQt.cpp:
+ (WebCore::RenderThemeQt::paintButton):
+ (WebCore::RenderThemeQt::paintTextField):
+ (WebCore::RenderThemeQt::paintMenuList):
+ (WebCore::RenderThemeQt::paintMenuListButton):
+ (WebCore::initPaletteFromPageClientIfExists):
+ (WebCore::RenderThemeQt::initializeCommonQStyleOptions):
+ * platform/qt/RenderThemeQt.h:
+
2009-12-30 Laszlo Gombos <laszlo.1.gombos at nokia.com>
Reviewed by Simon Hausmann.
diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp
index 04e31b9..e537afa 100644
--- a/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/WebCore/platform/qt/RenderThemeQt.cpp
@@ -43,10 +43,10 @@
#include "HTMLNames.h"
#include "NotImplemented.h"
#include "Page.h"
+#include "QWebPageClient.h"
#include "RenderBox.h"
#include "RenderTheme.h"
#include "UserAgentStyleSheets.h"
-#include "QWebPageClient.h"
#include "qwebpage.h"
#include <QApplication>
@@ -477,7 +477,7 @@ bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo&
option.rect = r;
option.state |= QStyle::State_Small;
- ControlPart appearance = applyTheme(option, o);
+ ControlPart appearance = initializeCommonQStyleOptions(option, o);
if (appearance == PushButtonPart || appearance == ButtonPart) {
option.rect = inflateButtonRect(option.rect, qStyle());
p.drawControl(QStyle::CE_PushButton, option);
@@ -513,7 +513,7 @@ bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInf
panel.features = QStyleOptionFrameV2::None;
// Get the correct theme data for a text field
- ControlPart appearance = applyTheme(panel, o);
+ ControlPart appearance = initializeCommonQStyleOptions(panel, o);
if (appearance != TextFieldPart
&& appearance != SearchFieldPart
&& appearance != TextAreaPart
@@ -575,7 +575,7 @@ bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo
QStyleOptionComboBox opt;
if (p.widget)
opt.initFrom(p.widget);
- applyTheme(opt, o);
+ initializeCommonQStyleOptions(opt, o);
const QPoint topLeft = r.topLeft();
p.painter->translate(topLeft);
@@ -615,7 +615,7 @@ bool RenderThemeQt::paintMenuListButton(RenderObject* o, const RenderObject::Pai
QStyleOptionComboBox option;
if (p.widget)
option.initFrom(p.widget);
- applyTheme(option, o);
+ initializeCommonQStyleOptions(option, o);
option.rect = r;
// for drawing the combo box arrow, rely only on the fallback style
@@ -712,7 +712,25 @@ bool RenderThemeQt::supportsFocus(ControlPart appearance) const
}
}
-ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const
+static inline void setPaletteFromPageClientIfExists(QPalette &palette, const RenderObject *o)
+{
+ // If the webview has a custom palette, use it
+ Page* page = o->document()->page();
+ if (!page)
+ return;
+ Chrome* chrome = page->chrome();
+ if (!chrome)
+ return;
+ ChromeClient* chromeClient = chrome->client();
+ if (!chromeClient)
+ return;
+ QWebPageClient* pageClient = chromeClient->platformPageClient();
+ if (!pageClient)
+ return;
+ palette = pageClient->palette();
+}
+
+ControlPart RenderThemeQt::initializeCommonQStyleOptions(QStyleOption& option, RenderObject* o) const
{
// Default bits: no focus, no mouse over
option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
@@ -724,19 +742,24 @@ ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) con
// Readonly is supported on textfields.
option.state |= QStyle::State_ReadOnly;
- if (supportsFocus(o->style()->appearance()) && isFocused(o)) {
- option.state |= QStyle::State_HasFocus;
- option.state |= QStyle::State_KeyboardFocusChange;
- }
+ option.direction = Qt::LeftToRight;
if (isHovered(o))
option.state |= QStyle::State_MouseOver;
- option.direction = Qt::LeftToRight;
- if (o->style() && o->style()->direction() == WebCore::RTL)
- option.direction = Qt::RightToLeft;
+ setPaletteFromPageClientIfExists(option.palette, o);
+ RenderStyle* style = o->style();
+ if (!style)
+ return NoControlPart;
- ControlPart result = o->style()->appearance();
+ ControlPart result = style->appearance();
+ if (supportsFocus(result) && isFocused(o)) {
+ option.state |= QStyle::State_HasFocus;
+ option.state |= QStyle::State_KeyboardFocusChange;
+ }
+
+ if (style->direction() == WebCore::RTL)
+ option.direction = Qt::RightToLeft;
switch (result) {
case PushButtonPart:
@@ -753,18 +776,9 @@ ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) con
option.state |= QStyle::State_Raised;
break;
}
- }
-
- if (result == RadioPart || result == CheckboxPart)
+ case RadioPart:
+ case CheckboxPart:
option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off);
-
- // If the owner widget has a custom palette, use it
- Page* page = o->document()->page();
- if (page) {
- ChromeClient* client = page->chrome()->client();
- QWebPageClient* pageClient = client->platformPageClient();
- if (pageClient)
- option.palette = pageClient->palette();
}
return result;
diff --git a/WebCore/platform/qt/RenderThemeQt.h b/WebCore/platform/qt/RenderThemeQt.h
index 617c875..b9cb918 100644
--- a/WebCore/platform/qt/RenderThemeQt.h
+++ b/WebCore/platform/qt/RenderThemeQt.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*
*/
-#ifndef RenderThemeQt_H
-#define RenderThemeQt_H
+#ifndef RenderThemeQt_h
+#define RenderThemeQt_h
#include "RenderTheme.h"
@@ -132,7 +132,7 @@ private:
private:
bool supportsFocus(ControlPart) const;
- ControlPart applyTheme(QStyleOption&, RenderObject*) const;
+ ControlPart initializeCommonQStyleOptions(QStyleOption&, RenderObject*) const;
void setButtonPadding(RenderStyle*) const;
void setPopupPadding(RenderStyle*) const;
@@ -180,4 +180,4 @@ private:
}
-#endif
+#endif // RenderThemeQt_h
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list