Changeset 102589 in webkit


Ignore:
Timestamp:
Dec 12, 2011 8:44:31 AM (12 years ago)
Author:
pierre.rossi@gmail.com
Message:

[Qt] Rendering issues with sliders and QStyle
https://bugs.webkit.org/show_bug.cgi?id=73921

With QStyle's origins being deeply rooted with widgets,
several styles make wrong assumptions, leading to sliders
not being painted properly in WebKit. We can solve a lot
of problems by systematically translating the painter to
the top left corner of the render object.

Reviewed by Simon Hausmann.

No new tests. The Qt tests are ran with the Windows
style, this fixes some quirks affecting other styles.

  • platform/qt/RenderThemeQStyle.cpp:

(WebCore::RenderThemeQStyle::paintSliderTrack):
(WebCore::RenderThemeQStyle::paintSliderThumb):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102588 r102589  
     12011-12-12  Pierre Rossi  <pierre.rossi@gmail.com>
     2
     3        [Qt] Rendering issues with sliders and QStyle
     4        https://bugs.webkit.org/show_bug.cgi?id=73921
     5
     6        With QStyle's origins being deeply rooted with widgets,
     7        several styles make wrong assumptions, leading to sliders
     8        not being painted properly in WebKit. We can solve a lot
     9        of problems by systematically translating the painter to
     10        the top left corner of the render object.
     11
     12        Reviewed by Simon Hausmann.
     13
     14        No new tests. The Qt tests are ran with the Windows
     15        style, this fixes some quirks affecting other styles.
     16
     17        * platform/qt/RenderThemeQStyle.cpp:
     18        (WebCore::RenderThemeQStyle::paintSliderTrack):
     19        (WebCore::RenderThemeQStyle::paintSliderThumb):
     20
    1212011-12-12  Mary Wu  <mary.wu@torchmobile.com.cn>
    222
  • trunk/Source/WebCore/platform/qt/RenderThemeQStyle.cpp

    r100270 r102589  
    6565#include <QMacStyle>
    6666#include <QPainter>
     67#ifndef QT_NO_STYLE_PLASTIQUE
    6768#include <QPlastiqueStyle>
     69#endif
    6870#include <QPushButton>
    6971#include <QStyleFactory>
     
    557559        return true;
    558560
     561    const QPoint topLeft = r.location();
     562    p.painter->translate(topLeft);
     563
    559564    QStyleOptionSlider option;
    560565    initStyleOption(p.widget, option);
     
    562567    ControlPart appearance = initializeCommonQStyleOptions(option, o);
    563568    option.rect = r;
     569    option.rect.moveTo(QPoint(0, 0));
    564570    if (appearance == SliderVerticalPart)
    565571        option.orientation = Qt::Vertical;
     
    567573        option.state |= QStyle::State_Sunken;
    568574
     575    // some styles need this to show a highlight on one side of the groove
     576    HTMLInputElement* slider = o->node()->toInputElement();
     577    if (slider) {
     578        option.upsideDown = (appearance == SliderHorizontalPart) && !o->style()->isLeftToRightDirection();
     579        // Use the width as a multiplier in case the slider values are <= 1
     580        const int width = r.width() > 0 ? r.width() : 100;
     581        option.maximum = slider->maximum() * width;
     582        option.minimum = slider->minimum() * width;
     583        if (!option.upsideDown)
     584            option.sliderPosition = slider->valueAsNumber() * width;
     585        else
     586            option.sliderPosition = option.minimum + option.maximum - slider->valueAsNumber() * width;
     587    }
     588
    569589    p.drawComplexControl(QStyle::CC_Slider, option);
    570590
     
    574594        p.drawPrimitive(QStyle::PE_FrameFocusRect, focusOption);
    575595    }
    576 
     596    p.painter->translate(-topLeft);
    577597    return false;
    578598}
     
    589609    if (!p.isValid())
    590610        return true;
     611
     612    const QPoint topLeft = r.location();
     613    p.painter->translate(topLeft);
    591614
    592615    QStyleOptionSlider option;
     
    595618    ControlPart appearance = initializeCommonQStyleOptions(option, o);
    596619    option.rect = r;
     620    option.rect.moveTo(QPoint(0, 0));
    597621    if (appearance == SliderThumbVerticalPart)
    598622        option.orientation = Qt::Vertical;
     
    603627
    604628    p.drawComplexControl(QStyle::CC_Slider, option);
    605 
     629    p.painter->translate(-topLeft);
    606630    return false;
    607631}
Note: See TracChangeset for help on using the changeset viewer.