summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/qt/RenderThemeQStyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/qt/RenderThemeQStyle.cpp')
-rw-r--r--Source/WebCore/platform/qt/RenderThemeQStyle.cpp54
1 files changed, 52 insertions, 2 deletions
diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp
index 999c670c4..59e74c282 100644
--- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp
+++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp
@@ -62,6 +62,20 @@ namespace WebCore {
using namespace HTMLNames;
+static QStyleFacade::ButtonSubElement indicatorSubElement(QStyleFacade::ButtonType part)
+{
+ switch (part) {
+ case QStyleFacade::CheckBox:
+ return QStyleFacade::CheckBoxIndicator;
+ case QStyleFacade::RadioButton:
+ return QStyleFacade::RadioButtonIndicator;
+ default:
+ break;
+ }
+ ASSERT_NOT_REACHED();
+ return QStyleFacade::CheckBoxIndicator;
+}
+
QSharedPointer<StylePainter> RenderThemeQStyle::getStylePainter(const PaintInfo& paintInfo)
{
return QSharedPointer<StylePainter>(new StylePainterQStyle(this, paintInfo, /*RenderObject*/0));
@@ -139,6 +153,11 @@ void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) cons
palette = pageClient->palette();
}
+QRect RenderThemeQStyle::indicatorRect(QStyleFacade::ButtonType part, const QRect& originalRect) const
+{
+ return m_qStyle->buttonSubElementRect(indicatorSubElement(part), QStyleFacade::State_Small, originalRect);
+}
+
QRect RenderThemeQStyle::inflateButtonRect(const QRect& originalRect) const
{
QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, originalRect);
@@ -153,6 +172,29 @@ QRect RenderThemeQStyle::inflateButtonRect(const QRect& originalRect) const
return originalRect;
}
+template<typename T>
+static void inflateCheckBoxRectImpl(T& originalRect, const QRect& rect)
+{
+ if (!rect.isNull()) {
+ int dx = static_cast<int>((rect.width() - originalRect.width()) / 2);
+ originalRect.setX(originalRect.x() - dx);
+ originalRect.setWidth(rect.width());
+ int dy = static_cast<int>((rect.height() - originalRect.height()) / 2);
+ originalRect.setY(originalRect.y() - dy);
+ originalRect.setHeight(rect.height());
+ }
+}
+
+void RenderThemeQStyle::computeControlRect(QStyleFacade::ButtonType part, QRect& originalRect) const
+{
+ inflateCheckBoxRectImpl(originalRect, indicatorRect(part, originalRect));
+}
+
+void RenderThemeQStyle::computeControlRect(QStyleFacade::ButtonType part, IntRect& originalRect) const
+{
+ inflateCheckBoxRectImpl(originalRect, indicatorRect(part, originalRect));
+}
+
int extendFixedPadding(Length oldPadding, int padding) {
if (oldPadding.isFixed()) {
return std::max(oldPadding.intValue(), padding);
@@ -306,10 +348,13 @@ bool RenderThemeQStyle::paintButton(RenderObject* o, const PaintInfo& i, const I
if (p.appearance == PushButtonPart || p.appearance == ButtonPart) {
p.styleOption.rect = inflateButtonRect(p.styleOption.rect);
p.paintButton(QStyleFacade::PushButton);
- } else if (p.appearance == RadioPart)
+ } else if (p.appearance == RadioPart) {
+ computeControlRect(QStyleFacade::RadioButton, p.styleOption.rect);
p.paintButton(QStyleFacade::RadioButton);
- else if (p.appearance == CheckboxPart)
+ } else if (p.appearance == CheckboxPart) {
+ computeControlRect(QStyleFacade::CheckBox, p.styleOption.rect);
p.paintButton(QStyleFacade::CheckBox);
+ }
return false;
}
@@ -546,6 +591,11 @@ ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleFacadeOption
option.state &= ~(QStyleFacade::State_HasFocus | QStyleFacade::State_MouseOver);
option.state |= QStyleFacade::State_Enabled;
+#ifdef Q_OS_DARWIN
+ // to render controls in correct positions we also should set the State_Active flag
+ option.state |= QStyleFacade::State_Active;
+#endif
+
if (isReadOnlyControl(o))
// Readonly is supported on textfields.
option.state |= QStyleFacade::State_ReadOnly;