Allow drawing a slider thumb for any nodes.
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jun 2011 02:06:38 +0000 (02:06 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jun 2011 02:06:38 +0000 (02:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=62196

Reviewed by Dimitri Glazkov.

Source/WebCore:

RenderObject::node() should provide various information which is
necessary for rendering. We don't need to refer the parent renderer.

* dom/Node.cpp:
(WebCore::Node::focusDe1egate): Added.
* dom/Node.h: Added a declaration.
* html/shadow/MediaControlElements.cpp:
(WebCore::toParentMediaElement):
  Added an overload of toParentMediaElement() with Node* parameter.
* html/shadow/MediaControlElements.h:
(WebCore::toParentMediaElement): ditto.
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::isEnabledFormControl):
  Returns the status of the host node.
(WebCore::SliderThumbElement::isReadOnlyFormControl): ditto.
(WebCore::SliderThumbElement::focusDe1egate):
  Returns the host node so that RenderTheme::isFocused() returns true.
(WebCore::SliderThumbElement::detach): Style nit.
(WebCore::SliderThumbElement::hostInput):
  Make it const because it is called by const functions.
* html/shadow/SliderThumbElement.h:
  - Remove inDragMode()
  - Update declarations
* platform/qt/RenderThemeQt.cpp:
(WebCore::RenderThemeQt::paintMediaSliderThumb):
  Use Node::shadowAncestorNode() instead of RenderObject::parent() to
  support deeper thumb nodes.
* rendering/RenderMediaControlsChromium.cpp:
(WebCore::paintMediaSliderThumb): ditto.
(WebCore::paintMediaVolumeSliderThumb): Remove isSlider() check.
* rendering/RenderSlider.cpp:
(WebCore::RenderSlider::inDragMode):
  SliderThumbElement::inDragMode() was removed, and Node::active() has
  the same information.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::paint): Remove isSlider() checks.
(WebCore::RenderTheme::isFocused): Apply Node::focusDelegate().
* rendering/RenderThemeChromiumLinux.cpp:
(WebCore::RenderThemeChromiumLinux::paintSliderThumb):
  isPressed() is enough.
* rendering/RenderThemeChromiumWin.cpp:
  isEnabled(), isFocused(), and isPressed() are enough.
(WebCore::RenderThemeChromiumWin::determineSliderThumbState):
(WebCore::RenderThemeChromiumWin::determineClassicState):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintSliderThumb):
  - Remove isSlider() check.
  - Passing 'o' to udpateFooState functions is enough.
  - isPressed() is enough.
* rendering/RenderThemeSafari.cpp:
(WebCore::RenderThemeSafari::paintSliderThumb):
  We don't need special handling anymore.
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::determineSliderThumbState):
  isEnabled(), isFocused(), and isPressed() are enough.

LayoutTests:

The behavior was changed. We should show slider thumbs for any nodes with
-webkit-appearance:slidertumb-horizontal/vertical.

* fast/forms/thumbslider-no-parent-slider.html:
* platform/chromium/test_expections.txt: Expect to fail with thumbslider-no-parent-slider.html.
* platform/mac/fast/forms/thumbslider-no-parent-slider-expected.png:
* platform/mac/fast/forms/thumbslider-no-parent-slider-expected.txt:

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/thumbslider-no-parent-slider.html
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/fast/forms/thumbslider-no-parent-slider-expected.png
LayoutTests/platform/mac/fast/forms/thumbslider-no-parent-slider-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControlElements.h
Source/WebCore/html/shadow/SliderThumbElement.cpp
Source/WebCore/html/shadow/SliderThumbElement.h
Source/WebCore/platform/qt/RenderThemeQt.cpp
Source/WebCore/rendering/RenderMediaControlsChromium.cpp
Source/WebCore/rendering/RenderSlider.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderThemeChromiumLinux.cpp
Source/WebCore/rendering/RenderThemeChromiumWin.cpp
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderThemeSafari.cpp
Source/WebCore/rendering/RenderThemeWin.cpp

index 39c0b71..d612d80 100644 (file)
@@ -1,3 +1,18 @@
+2011-06-08  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Allow drawing a slider thumb for any nodes.
+        https://bugs.webkit.org/show_bug.cgi?id=62196
+
+        The behavior was changed. We should show slider thumbs for any nodes with
+        -webkit-appearance:slidertumb-horizontal/vertical.
+
+        * fast/forms/thumbslider-no-parent-slider.html:
+        * platform/chromium/test_expections.txt: Expect to fail with thumbslider-no-parent-slider.html.
+        * platform/mac/fast/forms/thumbslider-no-parent-slider-expected.png:
+        * platform/mac/fast/forms/thumbslider-no-parent-slider-expected.txt:
+
 2011-06-08  James Kozianski  <koz@chromium.org>
 
         [Chromium] Unreviewed. Revert r88412 because it introduced syntax
index f263106..c28609b 100644 (file)
@@ -1,15 +1,23 @@
 <html>
 <head>
-    <style type="text/css">
-        #thumbHorizontal { -webkit-appearance: sliderthumb-horizontal; }
-        #thumbVertical { -webkit-appearance: sliderthumb-vertical; }
-    </style>
+<style type="text/css">
+#thumbHorizontal {
+    -webkit-appearance: sliderthumb-horizontal;
+    display: inline-block;
+    width: 20px;
+    height: 20px;
+}
+#thumbVertical {
+    -webkit-appearance: sliderthumb-vertical;
+    display: inline-block;
+    width: 20px;
+    height: 20px;
+}
+</style>
 </head>
 <body>
-    There should be no thumbsliders below, you should only see the words "Hello World" twice.
-    <br>
-    <br>
-    <span id="thumbHorizontal">Hello World</span><br>
-    <span id="thumbVertical">Hello World</span>
+<!-- There should be a horizontal slider thumb and a vertical slider thumb. -->
+<span id="thumbHorizontal"></span><br>
+<span id="thumbVertical"></span>
 </body>
 </html>
index fa4a5cf..3c6b9ac 100644 (file)
@@ -3208,6 +3208,7 @@ BUG_TKENT LEOPARD : platform/mac/fast/forms/input-appearance-spinbutton-up.html=
 BUG_TKENT LEOPARD : fast/forms/input-appearance-spinbutton-disabled-readonly.html = IMAGE
 BUG_TKENT LEOPARD : fast/forms/input-appearance-spinbutton-visibility.html = IMAGE
 BUG_TKENT LEOPARD : fast/forms/input-appearance-spinbutton-layer.html= IMAGE
+BUGWK62196 : fast/forms/thumbslider-no-parent-slider.html = FAIL
 
 // Need expectations
 BUGWK59281 WIN LINUX : fast/dom/HTMLMeterElement/meter-writing-mode.html = IMAGE+TEXT
index 68d7647..685eaed 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/forms/thumbslider-no-parent-slider-expected.png and b/LayoutTests/platform/mac/fast/forms/thumbslider-no-parent-slider-expected.png differ
index 7e6bb99..f1d641f 100644 (file)
@@ -3,15 +3,7 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderText {#text} at (0,0) size 592x18
-        text run at (0,0) width 592: "There should be no thumbsliders below, you should only see the words \"Hello World\" twice. "
-      RenderBR {BR} at (0,0) size 0x0
-      RenderBR {BR} at (0,18) size 0x18
-      RenderBlock {SPAN} at (0,36) size 79x18
-        RenderText {#text} at (0,0) size 79x18
-          text run at (0,0) width 79: "Hello World"
-      RenderBR {BR} at (79,50) size 0x0
-      RenderBlock {SPAN} at (0,54) size 79x18
-        RenderText {#text} at (0,0) size 79x18
-          text run at (0,0) width 79: "Hello World"
+      RenderBlock {SPAN} at (0,0) size 20x20
+      RenderBR {BR} at (20,20) size 0x0
+      RenderBlock {SPAN} at (0,20) size 20x20
       RenderText {#text} at (0,0) size 0x0
index a69f967..8df0fe6 100644 (file)
@@ -1,3 +1,66 @@
+2011-06-08  Kent Tamura  <tkent@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Allow drawing a slider thumb for any nodes.
+        https://bugs.webkit.org/show_bug.cgi?id=62196
+
+        RenderObject::node() should provide various information which is
+        necessary for rendering. We don't need to refer the parent renderer.
+
+        * dom/Node.cpp:
+        (WebCore::Node::focusDe1egate): Added.
+        * dom/Node.h: Added a declaration.
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::toParentMediaElement):
+          Added an overload of toParentMediaElement() with Node* parameter.
+        * html/shadow/MediaControlElements.h:
+        (WebCore::toParentMediaElement): ditto.
+        * html/shadow/SliderThumbElement.cpp:
+        (WebCore::SliderThumbElement::isEnabledFormControl):
+          Returns the status of the host node.
+        (WebCore::SliderThumbElement::isReadOnlyFormControl): ditto.
+        (WebCore::SliderThumbElement::focusDe1egate):
+          Returns the host node so that RenderTheme::isFocused() returns true.
+        (WebCore::SliderThumbElement::detach): Style nit.
+        (WebCore::SliderThumbElement::hostInput):
+          Make it const because it is called by const functions.
+        * html/shadow/SliderThumbElement.h:
+          - Remove inDragMode()
+          - Update declarations
+        * platform/qt/RenderThemeQt.cpp:
+        (WebCore::RenderThemeQt::paintMediaSliderThumb):
+          Use Node::shadowAncestorNode() instead of RenderObject::parent() to
+          support deeper thumb nodes.
+        * rendering/RenderMediaControlsChromium.cpp:
+        (WebCore::paintMediaSliderThumb): ditto.
+        (WebCore::paintMediaVolumeSliderThumb): Remove isSlider() check.
+        * rendering/RenderSlider.cpp:
+        (WebCore::RenderSlider::inDragMode):
+          SliderThumbElement::inDragMode() was removed, and Node::active() has
+          the same information.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::paint): Remove isSlider() checks.
+        (WebCore::RenderTheme::isFocused): Apply Node::focusDelegate().
+        * rendering/RenderThemeChromiumLinux.cpp:
+        (WebCore::RenderThemeChromiumLinux::paintSliderThumb):
+          isPressed() is enough.
+        * rendering/RenderThemeChromiumWin.cpp:
+          isEnabled(), isFocused(), and isPressed() are enough.
+        (WebCore::RenderThemeChromiumWin::determineSliderThumbState):
+        (WebCore::RenderThemeChromiumWin::determineClassicState):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintSliderThumb):
+          - Remove isSlider() check.
+          - Passing 'o' to udpateFooState functions is enough.
+          - isPressed() is enough.
+        * rendering/RenderThemeSafari.cpp:
+        (WebCore::RenderThemeSafari::paintSliderThumb):
+          We don't need special handling anymore.
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::RenderThemeWin::determineSliderThumbState):
+          isEnabled(), isFocused(), and isPressed() are enough.
+
 2011-06-08  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index bd41e52..35eab71 100644 (file)
@@ -963,6 +963,11 @@ bool Node::isMouseFocusable() const
     return isFocusable();
 }
 
+Node* Node::focusDelegate()
+{
+    return this;
+}
+
 unsigned Node::nodeIndex() const
 {
     Node *_tempNode = previousSibling();
index 6fc95fc..10646ce 100644 (file)
@@ -335,6 +335,7 @@ public:
     virtual bool isFocusable() const;
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;
+    virtual Node* focusDelegate();
 
     bool isContentEditable() const;
 
index 94cb3d6..ed52bec 100644 (file)
@@ -52,9 +52,8 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-HTMLMediaElement* toParentMediaElement(RenderObject* o)
+HTMLMediaElement* toParentMediaElement(Node* node)
 {
-    Node* node = o->node();
     Node* mediaNode = node ? node->shadowAncestorNode() : 0;
     if (!mediaNode || (!mediaNode->hasTagName(HTMLNames::videoTag) && !mediaNode->hasTagName(HTMLNames::audioTag)))
         return 0;
index ff8f461..896d466 100644 (file)
@@ -70,7 +70,8 @@ enum MediaControlElementType {
     MediaVolumeSliderMuteButton,
 };
 
-HTMLMediaElement* toParentMediaElement(RenderObject*);
+HTMLMediaElement* toParentMediaElement(Node*);
+inline HTMLMediaElement* toParentMediaElement(RenderObject* renderer) { return toParentMediaElement(renderer->node()); }
 
 // ----------------------------
 
index a49e3eb..591f738 100644 (file)
@@ -95,6 +95,21 @@ RenderObject* SliderThumbElement::createRenderer(RenderArena* arena, RenderStyle
     return new (arena) RenderSliderThumb(this);
 }
 
+bool SliderThumbElement::isEnabledFormControl() const
+{
+    return hostInput()->isEnabledFormControl();
+}
+
+bool SliderThumbElement::isReadOnlyFormControl() const
+{
+    return hostInput()->isReadOnlyFormControl();
+}
+
+Node* SliderThumbElement::focusDelegate()
+{
+    return hostInput();
+}
+
 void SliderThumbElement::dragFrom(const IntPoint& point)
 {
     setPositionFromPoint(point);
@@ -191,15 +206,17 @@ void SliderThumbElement::detach()
 {
     if (m_inDragMode) {
         if (Frame* frame = document()->frame())
-            frame->eventHandler()->setCapturingMouseEventsNode(0);      
+            frame->eventHandler()->setCapturingMouseEventsNode(0);
     }
     HTMLDivElement::detach();
 }
 
-HTMLInputElement* SliderThumbElement::hostInput()
+HTMLInputElement* SliderThumbElement::hostInput() const
 {
-    ASSERT(parentNode());
-    return static_cast<HTMLInputElement*>(parentNode()->shadowHost());
+    // Only HTMLInputElement creates SliderThumbElement instances as its shadow nodes.
+    // So, shadowAncestorNode() must be an HTMLInputElement.
+    HTMLInputElement* input = shadowAncestorNode()->toInputElement();
+    return input;
 }
 
 const AtomicString& SliderThumbElement::shadowPseudoId() const
index b29141f..52cae8c 100644 (file)
@@ -49,7 +49,6 @@ class SliderThumbElement : public HTMLDivElement {
 public:
     static PassRefPtr<SliderThumbElement> create(Document*);
 
-    bool inDragMode() const { return m_inDragMode; }
     void setPositionFromValue();
 
     void dragFrom(const IntPoint&);
@@ -61,10 +60,13 @@ private:
     SliderThumbElement(Document*);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren() const;
+    virtual bool isEnabledFormControl() const;
+    virtual bool isReadOnlyFormControl() const;
+    virtual Node* focusDelegate();
     void startDragging();
     void stopDragging();
     void setPositionFromPoint(const IntPoint&);
-    HTMLInputElement* hostInput();
+    HTMLInputElement* hostInput() const;
 
     bool m_inDragMode;
 };
index da19394..3006e5e 100644 (file)
@@ -1442,11 +1442,10 @@ bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const PaintInfo& pain
 
 bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
 {
-    if (!o->parent()->isSlider())
-        return false;
-
-    // We can get the HTMLMediaElement from the parent of the thumb : MediaControlTimelineElement.
-    HTMLMediaElement* mediaElement = toParentMediaElement(o->parent());
+    ASSERT(o->node());
+    Node* hostNode = o->node()->shadowAncestorNode();
+    ASSERT(hostNode);
+    HTMLMediaElement* mediaElement = toParentMediaElement(hostNode);
     if (!mediaElement)
         return false;
 
@@ -1457,7 +1456,7 @@ bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const PaintInfo& pain
     p.painter->setRenderHint(QPainter::Antialiasing, true);
 
     p.painter->setPen(Qt::NoPen);
-    p.painter->setBrush(getMediaControlForegroundColor(o->parent()));
+    p.painter->setBrush(getMediaControlForegroundColor(hostNode->renderer()));
     p.painter->drawRect(r.x(), r.y(), r.width(), r.height());
 
     return false;
index de5f594..5138b7a 100644 (file)
@@ -167,10 +167,10 @@ static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, c
 
 static bool paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (!object->parent()->isSlider())
-        return false;
-
-    HTMLMediaElement* mediaElement = toParentMediaElement(object->parent());
+    ASSERT(object->node());
+    Node* hostNode = object->node()->shadowAncestorNode();
+    ASSERT(hostNode);
+    HTMLMediaElement* mediaElement = toParentMediaElement(hostNode);
     if (!mediaElement)
         return false;
 
@@ -202,9 +202,6 @@ static bool paintMediaVolumeSlider(RenderObject* object, const PaintInfo& paintI
 
 static bool paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (!object->parent()->isSlider())
-        return false;
-
     static Image* mediaVolumeSliderThumb = platformResource("mediaVolumeSliderThumb");
     return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb);
 }
index 2b84999..a4e4a3b 100644 (file)
@@ -186,7 +186,7 @@ SliderThumbElement* RenderSlider::shadowSliderThumb() const
 bool RenderSlider::inDragMode() const
 {
     SliderThumbElement* thumbElement = shadowSliderThumb();
-    return thumbElement && thumbElement->inDragMode();
+    return thumbElement && thumbElement->active();
 }
 
 } // namespace WebCore
index ee2d0b8..1095382 100644 (file)
@@ -306,10 +306,7 @@ bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe
             return paintSliderTrack(o, paintInfo, r);
         case SliderThumbHorizontalPart:
         case SliderThumbVerticalPart:
-            if (o->parent()->isSlider())
-                return paintSliderThumb(o, paintInfo, r);
-            // We don't support drawing a slider thumb without a parent slider
-            break;
+            return paintSliderThumb(o, paintInfo, r);
         case MediaFullscreenButtonPart:
             return paintMediaFullscreenButton(o, paintInfo, r);
         case MediaPlayButtonPart:
@@ -329,9 +326,7 @@ bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe
         case MediaSliderPart:
             return paintMediaSliderTrack(o, paintInfo, r);
         case MediaSliderThumbPart:
-            if (o->parent()->isSlider())
-                return paintMediaSliderThumb(o, paintInfo, r);
-            break;
+            return paintMediaSliderThumb(o, paintInfo, r);
         case MediaVolumeSliderMuteButtonPart:
             return paintMediaMuteButton(o, paintInfo, r);
         case MediaVolumeSliderContainerPart:
@@ -339,9 +334,7 @@ bool RenderTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe
         case MediaVolumeSliderPart:
             return paintMediaVolumeSliderTrack(o, paintInfo, r);
         case MediaVolumeSliderThumbPart:
-            if (o->parent()->isSlider())
-                return paintMediaVolumeSliderThumb(o, paintInfo, r);
-            break;
+            return paintMediaVolumeSliderThumb(o, paintInfo, r);
         case MediaTimeRemainingPart:
             return paintMediaTimeRemaining(o, paintInfo, r);
         case MediaCurrentTimePart:
@@ -777,6 +770,8 @@ bool RenderTheme::isFocused(const RenderObject* o) const
     Node* node = o->node();
     if (!node)
         return false;
+
+    node = node->focusDelegate();
     Document* document = node->document();
     Frame* frame = document->frame();
     return node == document->focusedNode() && frame && frame->selection()->isFocusedAndActive();
index 7af14c2..d39911b 100644 (file)
@@ -296,7 +296,7 @@ bool RenderThemeChromiumLinux::paintSliderThumb(RenderObject* o, const PaintInfo
 {
     PlatformBridge::ThemePaintExtraParams extraParams;
     extraParams.slider.vertical = o->style()->appearance() == SliderThumbVerticalPart;
-    extraParams.slider.inDrag = toRenderSlider(o->parent())->inDragMode();
+    extraParams.slider.inDrag = isPressed(o);
 
     PlatformBridge::paintThemePart(i.context, PlatformBridge::PartSliderThumb, getWebThemeState(this, o), rect, &extraParams);
     return false;
index f289637..414fa81 100644 (file)
@@ -560,11 +560,11 @@ unsigned RenderThemeChromiumWin::determineState(RenderObject* o, ControlSubPart
 unsigned RenderThemeChromiumWin::determineSliderThumbState(RenderObject* o)
 {
     unsigned result = TUS_NORMAL;
-    if (!isEnabled(o->parent()))
+    if (!isEnabled(o))
         result = TUS_DISABLED;
-    else if (supportsFocus(o->style()->appearance()) && isFocused(o->parent()))
+    else if (supportsFocus(o->style()->appearance()) && isFocused(o))
         result = TUS_FOCUSED;
-    else if (toRenderSlider(o->parent())->inDragMode())
+    else if (isPressed(o))
         result = TUS_PRESSED;
     else if (isHovered(o))
         result = TUS_HOT;
@@ -586,9 +586,9 @@ unsigned RenderThemeChromiumWin::determineClassicState(RenderObject* o, ControlS
         return result;   
 
     if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) {
-        if (!isEnabled(o->parent()))
+        if (!isEnabled(o))
             result = DFCS_INACTIVE;
-        else if (toRenderSlider(o->parent())->inDragMode()) // Active supersedes hover
+        else if (isPressed(o)) // Active supersedes hover
             result = DFCS_PUSHED;
         else if (isHovered(o))
             result = DFCS_HOT;
index 1d22777..d050826 100644 (file)
@@ -1299,8 +1299,6 @@ const float verticalSliderHeightPadding = 0.1f;
 
 bool RenderThemeMac::paintSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
 {
-    ASSERT(o->parent()->isSlider());
-
     NSSliderCell* sliderThumbCell = o->style()->appearance() == SliderThumbVerticalPart
         ? sliderThumbVertical()
         : sliderThumbHorizontal();
@@ -1308,9 +1306,9 @@ bool RenderThemeMac::paintSliderThumb(RenderObject* o, const PaintInfo& paintInf
     LocalCurrentGraphicsContext localContext(paintInfo.context);
 
     // Update the various states we respond to.
-    updateActiveState(sliderThumbCell, o->parent());
-    updateEnabledState(sliderThumbCell, o->parent());
-    updateFocusedState(sliderThumbCell, o->parent());
+    updateActiveState(sliderThumbCell, o);
+    updateEnabledState(sliderThumbCell, o);
+    updateFocusedState(sliderThumbCell, o);
 
     // Update the pressed state using the NSCell tracking methods, since that's how NSSliderCell keeps track of it.
     bool oldPressed;
@@ -1319,7 +1317,7 @@ bool RenderThemeMac::paintSliderThumb(RenderObject* o, const PaintInfo& paintInf
     else
         oldPressed = m_isSliderThumbHorizontalPressed;
 
-    bool pressed = toRenderSlider(o->parent())->inDragMode();
+    bool pressed = isPressed(o);
 
     if (o->style()->appearance() == SliderThumbVerticalPart)
         m_isSliderThumbVerticalPressed = pressed;
index ee5e68a..0037208 100644 (file)
@@ -999,16 +999,7 @@ const float verticalSliderHeightPadding = 0.1f;
 bool RenderThemeSafari::paintSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
 {
     ASSERT(SafariThemeLibrary());
-
-    ASSERT(o->parent()->isSlider());
-
-    bool pressed = toRenderSlider(o->parent())->inDragMode();
-    ThemeControlState state = determineState(o->parent());
-    state &= ~SafariTheme::PressedState;
-    if (pressed)
-        state |= SafariTheme::PressedState;
-
-    paintThemePart(SliderThumbPart, paintInfo.context->platformContext(), r, NSSmallControlSize, state);
+    paintThemePart(SliderThumbPart, paintInfo.context->platformContext(), r, NSSmallControlSize, determineState(o));
     return false;
 }
 
index 68c8ad1..bebfa45 100644 (file)
@@ -463,11 +463,11 @@ unsigned RenderThemeWin::determineState(RenderObject* o)
 unsigned RenderThemeWin::determineSliderThumbState(RenderObject* o)
 {
     unsigned result = TUS_NORMAL;
-    if (!isEnabled(o->parent()))
+    if (!isEnabled(o))
         result = TUS_DISABLED;
-    else if (supportsFocus(o->style()->appearance()) && isFocused(o->parent()))
+    else if (supportsFocus(o->style()->appearance()) && isFocused(o))
         result = TUS_FOCUSED;
-    else if (toRenderSlider(o->parent())->inDragMode())
+    else if (isPressed(o))
         result = TUS_PRESSED;
     else if (isHovered(o))
         result = TUS_HOT;