2009-03-27 Zack Rusin <zack@kde.org>
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2009 17:40:45 +0000 (17:40 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2009 17:40:45 +0000 (17:40 +0000)
        Reviewed by Tor Arne Vestbø.

        https://bugs.webkit.org/show_bug.cgi?id=24275

        Fix text field theming in the Qt build with the KDE 4 Oxygen
        style by adjusting the size vertically and horizontally to
        set padding on the element equal to the width of the style painted border.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@42038 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/qt/RenderThemeQt.cpp
WebCore/platform/qt/RenderThemeQt.h

index 70045a2..d91d4c8 100644 (file)
@@ -1,3 +1,20 @@
+2009-03-27  Zack Rusin <zack@kde.org>
+
+        Reviewed by Tor Arne Vestbø.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24275
+
+        Fix text field theming in the Qt build with the KDE 4 Oxygen
+        style by adjusting the size vertically and horizontally to
+        set padding on the element equal to the width of the style painted border.
+
+        * platform/qt/RenderThemeQt.cpp:
+        (WebCore::RenderThemeQt::RenderThemeQt):
+        (WebCore::RenderThemeQt::computeSizeBasedOnStyle):
+        (WebCore::RenderThemeQt::adjustTextFieldStyle):
+        (WebCore::RenderThemeQt::paintTextField):
+        * platform/qt/RenderThemeQt.h:
+
 2009-03-27  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         Reviewed by Simon Hausmann.
index 942e95b..5a9f025 100644 (file)
@@ -41,6 +41,7 @@
 #include <QWidget>
 #include <QPainter>
 #include <QPushButton>
+#include <QLineEdit>
 #include <QStyleFactory>
 #include <QStyleOptionButton>
 #include <QStyleOptionFrameV2>
@@ -124,6 +125,12 @@ RenderThemeQt::RenderThemeQt()
 #endif
 
     m_fallbackStyle = 0;
+
+    // this will need to be regenerated when the style changes
+    QLineEdit lineEdit;
+    QStyleOptionFrameV2 opt;
+    m_frameLineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth,
+                                                          &opt, &lineEdit);
 }
 
 RenderThemeQt::~RenderThemeQt()
@@ -272,7 +279,7 @@ int RenderThemeQt::minimumMenuListSize(RenderStyle*) const
     return 7 * fm.width(QLatin1Char('x'));
 }
 
-static void computeSizeBasedOnStyle(RenderStyle* renderStyle)
+void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
 {
     // If the width and height are both specified, then we have nothing to do.
     if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto())
@@ -339,13 +346,15 @@ static void computeSizeBasedOnStyle(RenderStyle* renderStyle)
         int h = qMax(fm.lineSpacing(), 14) + 2*verticalMargin;
         int w = fm.width(QLatin1Char('x')) * 17 + 2*horizontalMargin;
         QStyleOptionFrameV2 opt;
-        opt.lineWidth = applicationStyle->pixelMetric(QStyle::PM_DefaultFrameWidth,
-                                                           &opt, 0);
+        opt.lineWidth = m_frameLineWidth;
         QSize sz = applicationStyle->sizeFromContents(QStyle::CT_LineEdit,
-                                                           &opt,
-                                                           QSize(w, h).expandedTo(QApplication::globalStrut()),
-                                                           0);
+                                                      &opt,
+                                                      QSize(w, h).expandedTo(QApplication::globalStrut()),
+                                                      0);
         size.setHeight(sz.height());
+
+        renderStyle->setPaddingLeft(Length(opt.lineWidth, Fixed));
+        renderStyle->setPaddingRight(Length(opt.lineWidth, Fixed));
         break;
     }
     default:
@@ -486,6 +495,9 @@ void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style,
 {
     style->setBackgroundColor(Color::transparent);
     style->setColor(QApplication::palette().text().color());
+    style->resetBorder();
+    style->resetPadding();
+    computeSizeBasedOnStyle(style);
 }
 
 bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
@@ -499,7 +511,7 @@ bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInf
         panel.initFrom(p.widget);
 
     panel.rect = r;
-    panel.lineWidth = p.style->pixelMetric(QStyle::PM_DefaultFrameWidth, &panel, p.widget);
+    panel.lineWidth = m_frameLineWidth;
     panel.state |= QStyle::State_Sunken;
     panel.features = QStyleOptionFrameV2::None;
 
index b4a5064..5c78a72 100644 (file)
@@ -128,6 +128,7 @@ private:
     void paintMediaBackground(QPainter* painter, const IntRect& r) const;
     QColor getMediaControlForegroundColor(RenderObject* o = 0) const;
 #endif
+    void computeSizeBasedOnStyle(RenderStyle* renderStyle) const;
 
 private:
     bool supportsFocus(ControlPart) const;
@@ -144,6 +145,8 @@ private:
 
     QStyle* m_fallbackStyle;
     QStyle* fallbackStyle();
+
+    int m_frameLineWidth;
 };
 
 class StylePainter