2009-03-20 Peter Kasting <pkasting@google.com>
authorpkasting@chromium.org <pkasting@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2009 19:02:59 +0000 (19:02 +0000)
committerpkasting@chromium.org <pkasting@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2009 19:02:59 +0000 (19:02 +0000)
        Reviewed by Darin Fisher.

        https://bugs.webkit.org/show_bug.cgi?id=24720
        RenderThemeChromium should draw something for Slider parts instead of
        dropping them on the floor.

        * platform/chromium/ChromiumBridge.h:
        * rendering/RenderThemeChromiumWin.cpp:
        (WebCore::RenderThemeChromiumWin::adjustSliderThumbSize):
        (WebCore::RenderThemeChromiumWin::paintSliderTrack):
        (WebCore::RenderThemeChromiumWin::determineSliderThumbState):
        (WebCore::RenderThemeChromiumWin::getThemeData):
        * rendering/RenderThemeChromiumWin.h:
        (WebCore::RenderThemeChromiumWin::paintSliderThumb):

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

WebCore/ChangeLog
WebCore/platform/chromium/ChromiumBridge.h
WebCore/rendering/RenderThemeChromiumWin.cpp
WebCore/rendering/RenderThemeChromiumWin.h

index fc17a561e17340c90151bbbcb3d1ef2c07147442..3541c249aaa20d0057b3a7f96b8b611344e48293 100644 (file)
@@ -1,3 +1,20 @@
+2009-03-20  Peter Kasting  <pkasting@google.com>
+
+        Reviewed by Darin Fisher.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24720
+        RenderThemeChromium should draw something for Slider parts instead of
+        dropping them on the floor.
+
+        * platform/chromium/ChromiumBridge.h:
+        * rendering/RenderThemeChromiumWin.cpp:
+        (WebCore::RenderThemeChromiumWin::adjustSliderThumbSize):
+        (WebCore::RenderThemeChromiumWin::paintSliderTrack):
+        (WebCore::RenderThemeChromiumWin::determineSliderThumbState):
+        (WebCore::RenderThemeChromiumWin::getThemeData):
+        * rendering/RenderThemeChromiumWin.h:
+        (WebCore::RenderThemeChromiumWin::paintSliderThumb):
+
 2009-03-23  Glen Murphy  <glen@chromium.org>
 
         Reviewed by Darin Fisher.
index 20943c8a5559ddec41ccc3b7f238496acca21cac..3e5c40433fd02a5bce4a89aaedcfc01d56d4a477 100644 (file)
@@ -152,6 +152,8 @@ namespace WebCore {
             GraphicsContext*, int part, int state, int classicState, const IntRect&, const IntRect& alignRect);
         static void paintTextField(
             GraphicsContext*, int part, int state, int classicState, const IntRect&, const Color&, bool fillContentArea, bool drawEdges);
+        static void paintTrackbar(
+            GraphicsContext*, int part, int state, int classicState, const IntRect&);
 #endif
 
         // Trace Event --------------------------------------------------------
index 463f008cca9ec22199e19d204a4e3282b3f92415..30f421bd9bfd6bce2c2637c09292d5cf2b2964fe 100644 (file)
@@ -36,6 +36,7 @@
 #include "FontUtilsChromiumWin.h"
 #include "GraphicsContext.h"
 #include "RenderBox.h"
+#include "RenderSlider.h"
 #include "ScrollbarTheme.h"
 #include "SkiaUtils.h"
 #include "TransparencyWin.h"
@@ -395,6 +396,20 @@ int RenderThemeChromiumWin::minimumMenuListSize(RenderStyle* style) const
     return 0;
 }
 
+void RenderThemeChromiumWin::adjustSliderThumbSize(RenderObject* o) const
+{
+    // These sizes match what WinXP draws for various menus.
+    const int sliderThumbAlongAxis = 11;
+    const int sliderThumbAcrossAxis = 21;
+    if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->appearance() == MediaSliderThumbPart) {
+        o->style()->setWidth(Length(sliderThumbAlongAxis, Fixed));
+        o->style()->setHeight(Length(sliderThumbAcrossAxis, Fixed));
+    } else if (o->style()->appearance() == SliderThumbVerticalPart) {
+        o->style()->setWidth(Length(sliderThumbAcrossAxis, Fixed));
+        o->style()->setHeight(Length(sliderThumbAlongAxis, Fixed));
+    }
+}
+
 void RenderThemeChromiumWin::setCheckboxSize(RenderStyle* style) const
 {
     // If the width and height are both specified, then we have nothing to do.
@@ -434,6 +449,19 @@ bool RenderThemeChromiumWin::paintTextField(RenderObject* o, const RenderObject:
     return paintTextFieldInternal(o, i, r, true);
 }
 
+bool RenderThemeChromiumWin::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
+{
+    const ThemeData& themeData = getThemeData(o);
+
+    WebCore::ThemePainter painter(i.context, r);
+    ChromiumBridge::paintTrackbar(painter.context(),
+                                  themeData.m_part,
+                                  themeData.m_state,
+                                  themeData.m_classicState,
+                                  painter.drawRect());
+    return false;
+}
+
 bool RenderThemeChromiumWin::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
 {
     return paintTextField(o, i, r);
@@ -575,6 +603,20 @@ unsigned RenderThemeChromiumWin::determineState(RenderObject* o)
     return result;
 }
 
+unsigned RenderThemeChromiumWin::determineSliderThumbState(RenderObject* o)
+{
+    unsigned result = TUS_NORMAL;
+    if (!isEnabled(o->parent()))
+        result = TUS_DISABLED;
+    else if (supportsFocus(o->style()->appearance()) && isFocused(o->parent()))
+        result = TUS_FOCUSED;
+    else if (static_cast<RenderSlider*>(o->parent())->inDragMode())
+        result = TUS_PRESSED;
+    else if (isHovered(o))
+        result = TUS_HOT;
+    return result;
+}
+
 unsigned RenderThemeChromiumWin::determineClassicState(RenderObject* o)
 {
     unsigned result = 0;
@@ -593,29 +635,48 @@ ThemeData RenderThemeChromiumWin::getThemeData(RenderObject* o)
 {
     ThemeData result;
     switch (o->style()->appearance()) {
-    case PushButtonPart:
-    case ButtonPart:
-        result.m_part = BP_PUSHBUTTON;
-        result.m_classicState = DFCS_BUTTONPUSH;
-        break;
     case CheckboxPart:
         result.m_part = BP_CHECKBOX;
+        result.m_state = determineState(o);
         result.m_classicState = DFCS_BUTTONCHECK;
         break;
     case RadioPart:
         result.m_part = BP_RADIOBUTTON;
+        result.m_state = determineState(o);
         result.m_classicState = DFCS_BUTTONRADIO;
         break;
+    case PushButtonPart:
+    case ButtonPart:
+        result.m_part = BP_PUSHBUTTON;
+        result.m_state = determineState(o);
+        result.m_classicState = DFCS_BUTTONPUSH;
+        break;
+    case SliderHorizontalPart:
+        result.m_part = TKP_TRACK;
+        result.m_state = TRS_NORMAL;
+        break;
+    case SliderVerticalPart:
+        result.m_part = TKP_TRACKVERT;
+        result.m_state = TRVS_NORMAL;
+        break;
+    case SliderThumbHorizontalPart:
+        result.m_part = TKP_THUMBBOTTOM;
+        result.m_state = determineSliderThumbState(o);
+        break;
+    case SliderThumbVerticalPart:
+        result.m_part = TKP_THUMBVERT;
+        result.m_state = determineSliderThumbState(o);
+        break;
     case ListboxPart:
     case MenulistPart:
     case SearchFieldPart:
     case TextFieldPart:
     case TextAreaPart:
-        result.m_part = ETS_NORMAL;
+        result.m_part = EP_EDITTEXT;
+        result.m_state = determineState(o);
         break;
     }
 
-    result.m_state = determineState(o);
     result.m_classicState |= determineClassicState(o);
 
     return result;
index 0866cfeb1a32094c77847c271a17fbd5c4ddddcc..f1ef306ee1bb4f9cbd94a4fc35202e23c0cd220d 100644 (file)
@@ -70,6 +70,8 @@ namespace WebCore {
 
         virtual int minimumMenuListSize(RenderStyle*) const;
 
+        virtual void adjustSliderThumbSize(RenderObject*) const;
+
         virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintButton(o, i, r); }
         virtual void setCheckboxSize(RenderStyle*) const;
 
@@ -82,6 +84,10 @@ namespace WebCore {
 
         virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); }
 
+        virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+
+        virtual bool paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintSliderTrack(o, i, r); }
+
         virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
 
         // MenuList refers to an unstyled menulist (meaning a menulist without
@@ -122,6 +128,7 @@ namespace WebCore {
 
     private:
         unsigned determineState(RenderObject*);
+        unsigned determineSliderThumbState(RenderObject*);
         unsigned determineClassicState(RenderObject*);
 
         ThemeData getThemeData(RenderObject*);