Bug 39421 - [Qt] Vertical slider rendered upside down
Summary: [Qt] Vertical slider rendered upside down
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P3 Normal
Assignee: Nobody
URL:
Keywords: Qt
Depends on:
Blocks:
 
Reported: 2010-05-20 04:59 PDT by Andrew Webster
Modified: 2010-06-15 01:01 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Webster 2010-05-20 04:59:51 PDT
The bar for vertical sliders using the <input type="range"> tag seem to be rendered with the minimum value at the top of the slider rather than the bottom (the handle however appears in the correct location).  This is only obvious when using a style that renders the bar differently above and below the handle, such as QCleanlooksStyle.

I am using the HEAD from the qtwebkit-2.0 branch and Qt 4.6.2 on Embedded Linux (qws).  I have confirmed the same behavior under Windows.

To reproduce, load the following in a QWebView using the QCleanlooksStyle:

<html>
<head>
<style>      
      input[type="range"].v {
         width: 100px;
         height: 200px;
        -webkit-appearance: slider-vertical;
      }      
      input[type="range"].h {
         width: 200px;
         height: 100px;
        -webkit-appearance: slider-horizontal;
      }
</style>
</head>
<body>
    <input id="slide1" class="h" type="range" min="0" max="100" />
    <input id="slide2" class="v" type="range" min="0" max="100" />
</body>
</html>

The horizontal slider will have the blue section of the slider between the left side and the handle, however the vertical slider will have the blue section between the top and the handle.  The blue section should be between the bottom and the handle.

The following patch makes the vertical slider render properly with QCleanlooksStyle and makes the rendering more consistent with QSlider:

diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp
index 577903b..6be018b 100644
--- a/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/WebCore/platform/qt/RenderThemeQt.cpp
@@ -746,6 +746,10 @@ bool RenderThemeQt::paintSliderTrack(RenderObject* o, const RenderObject::PaintI
     IntRect thumbRect = renderSlider->thumbRect();
 
     option.rect = r;
+    
+    option.upsideDown = (appearance == SliderHorizontalPart) ?
+                     (option.direction == Qt::RightToLeft)
+                     : true;
 
     int value;
     if (appearance == SliderVerticalPart) {
@@ -756,7 +760,7 @@ bool RenderThemeQt::paintSliderTrack(RenderObject* o, const RenderObject::PaintI
         value = thumbRect.x();
     }
 
-    value = QStyle::sliderValueFromPosition(0, option.maximum, value, option.maximum);
+    value = QStyle::sliderValueFromPosition(0, option.maximum, value, option.maximum, option.upsideDown);
 
     option.sliderValue = value;
     option.sliderPosition = value;
Comment 1 Balazs Kelemen 2010-06-03 04:58:23 PDT
Please follow the instructions about contributing as stated in:
http://webkit.org/coding/contributing.html.
Actually, this is not a big deal in that case. Yo should create a layouttest from
your html test case, and create a patch with a changelog based on your change :)
Comment 2 Kent Hansen 2010-06-15 01:01:32 PDT
Marking as invalid until Balazs's comment has been acted upon.