Patch from Qing Zhao to draw focus rects on non-QStyle rendered nodes. Needs a
authorstaikos <staikos@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2007 22:13:33 +0000 (22:13 +0000)
committerstaikos <staikos@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2007 22:13:33 +0000 (22:13 +0000)
bit more work once we figure out how to use QPainterPathStroker in a more
sophisticated manner.

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

WebCore/ChangeLog
WebCore/platform/graphics/qt/GraphicsContextQt.cpp
WebCore/platform/qt/RenderThemeQt.cpp

index bf7c64a53a5f4cf31b2cf53bcc776046d8bcfd9c..18c34279c9212758dcf8493c17d4009c635ab2ad 100644 (file)
@@ -1,3 +1,16 @@
+2007-07-10  Qing Zhao  <qing@staikos.net>
+
+        Reviewed by George Staikos.
+
+        Draw focus rings for nodes that are not rendered by QStyle.
+
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::focusRingColor):
+        (WebCore::GraphicsContext::drawFocusRing):
+        * platform/qt/RenderThemeQt.cpp:
+        (WebCore::RenderThemeQt::supportsFocusRing):
+        (WebCore::RenderThemeQt::supportsFocus):
+
 2007-07-10  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Geoff.
index 4ce4395152284be20c243b390cb9e08efcd01a4f..4d5c9e769dc02b4f3ee8620d63a15c03223166b4 100644 (file)
@@ -45,6 +45,7 @@
 #include <QPolygonF>
 #include <QPainterPath>
 #include <QPaintDevice>
+#include <QDebug>
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -533,25 +534,36 @@ void GraphicsContext::clip(const IntRect& rect)
  * need it.
  */
 void setFocusRingColorChangeFunction(void (*)()) { }
-Color focusRingColor() { return 0x00000000; }
+Color focusRingColor() { return Color(0, 0, 0); }
 void GraphicsContext::drawFocusRing(const Color& color)
 {
     if (paintingDisabled())
         return;
 
-    return;
-
     const Vector<IntRect>& rects = focusRingRects();
     unsigned rectCount = rects.size();
 
-    QVector<QRect> qrects(rectCount);
-    for (int i = 0; i < rectCount; ++i)
-        qrects[i] = rects[i];
-    m_data->p().save();
-    m_data->p().setClipRect(m_data->focusRingClip);
-    m_data->p().setPen(color);
-    m_data->p().drawRects(qrects);
-    m_data->p().restore();
+    if (rects.size() > 1)
+    {
+        QPainterPath path;
+        for (int i = 0; i < rectCount; ++i)
+            path.addRect(QRectF(rects[i]));
+        m_data->p().save();
+        QPen nPen = m_data->p().pen();
+        nPen.setColor(color);
+        m_data->p().setBrush(Qt::NoBrush);
+        nPen.setStyle(Qt::DotLine);
+        m_data->p().setPen(nPen);
+#if 0
+        // FIXME How do we do a bounding outline with Qt?
+        QPainterPathStroker stroker;
+        QPainterPath newPath = stroker.createStroke(path);
+        m_data->p().strokePath(newPath, nPen);
+#else
+        m_data->p().drawRect(path.boundingRect());
+#endif
+        m_data->p().restore();
+    }
 }
 
 void GraphicsContext::setFocusRingClip(const IntRect& rect)
index d5f3ec45510dc53e73c2b97df97243a22ebf05bf..1d7bfe9a3b517b21d24d2baeb343d48f0fb4a534 100644 (file)
@@ -63,7 +63,7 @@ bool RenderThemeQt::supportsHover(const RenderStyle*) const
 
 bool RenderThemeQt::supportsFocusRing(const RenderStyle* style) const
 {
-    return true;
+    return supportsFocus(style->appearance());
 }
 
 short RenderThemeQt::baselinePosition(const RenderObject* o) const
@@ -400,6 +400,8 @@ bool RenderThemeQt::supportsFocus(EAppearance appearance) const
         case ButtonAppearance:
         case TextFieldAppearance:
         case MenulistAppearance:
+        case RadioAppearance:
+        case CheckboxAppearance:
             return true;
         default: // No for all others...
             return false;