| Differences between
and this patch
- a/WebCore/ChangeLog +16 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2010-12-16  Ariya Hidayat  <ariya@sencha.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        [Qt] GraphicsContext should respect QWebView render hints
6
        https://bugs.webkit.org/show_bug.cgi?id=51208
7
8
        GraphicsContext does not override SmoothPixmapTransform (see also
9
        r62762). To keep the same behavior, canvas default image interpolation
10
        quality is set to medium and QWebView's render hints by default also
11
        include SmoothPixmapTransform.
12
13
        * html/HTMLCanvasElement.h:
14
        * platform/graphics/qt/GraphicsContextQt.cpp:
15
        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
16
1
2010-12-16  Daniel Bates  <dbates@rim.com>
17
2010-12-16  Daniel Bates  <dbates@rim.com>
2
18
3
        Reviewed by Antonio Gomes.
19
        Reviewed by Antonio Gomes.
- a/WebCore/html/HTMLCanvasElement.h -1 / +1 lines
Lines 32-38 a/WebCore/html/HTMLCanvasElement.h_sec1
32
#include "HTMLElement.h"
32
#include "HTMLElement.h"
33
#include "IntSize.h"
33
#include "IntSize.h"
34
34
35
#if PLATFORM(CHROMIUM)
35
#if PLATFORM(CHROMIUM) || PLATFORM(QT)
36
#define DefaultInterpolationQuality InterpolationMedium
36
#define DefaultInterpolationQuality InterpolationMedium
37
#elif PLATFORM(CG)
37
#elif PLATFORM(CG)
38
#define DefaultInterpolationQuality InterpolationLow
38
#define DefaultInterpolationQuality InterpolationLow
- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp -1 / +1 lines
Lines 237-243 GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p, cons a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp_sec1
237
    // Use the default the QPainter was constructed with.
237
    // Use the default the QPainter was constructed with.
238
    antiAliasingForRectsAndLines = painter->testRenderHint(QPainter::Antialiasing);
238
    antiAliasingForRectsAndLines = painter->testRenderHint(QPainter::Antialiasing);
239
239
240
    painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true);
240
    painter->setRenderHint(QPainter::Antialiasing, true);
241
}
241
}
242
242
243
GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
243
GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
- a/WebKit/qt/Api/qwebview.cpp -2 / +2 lines
Lines 39-45 public: a/WebKit/qt/Api/qwebview.cpp_sec1
39
    QWebViewPrivate(QWebView *view)
39
    QWebViewPrivate(QWebView *view)
40
        : view(view)
40
        : view(view)
41
        , page(0)
41
        , page(0)
42
        , renderHints(QPainter::TextAntialiasing)
42
        , renderHints(QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform)
43
    {
43
    {
44
        Q_ASSERT(view);
44
        Q_ASSERT(view);
45
    }
45
    }
Lines 713-719 qreal QWebView::textSizeMultiplier() const a/WebKit/qt/Api/qwebview.cpp_sec2
713
713
714
    These hints are used to initialize QPainter before painting the Web page.
714
    These hints are used to initialize QPainter before painting the Web page.
715
715
716
    QPainter::TextAntialiasing is enabled by default.
716
    QPainter::TextAntialiasing and QPainter::SmoothPixmapTransform are enabled by default.
717
717
718
    \note This property is not available on Symbian. However, the getter and
718
    \note This property is not available on Symbian. However, the getter and
719
    setter functions can still be used directly.
719
    setter functions can still be used directly.
- a/WebKit/qt/ChangeLog +14 lines
Lines 1-3 a/WebKit/qt/ChangeLog_sec1
1
2010-12-16  Ariya Hidayat  <ariya@sencha.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        [Qt] GraphicsContext should respect QWebView render hints
6
        https://bugs.webkit.org/show_bug.cgi?id=51208
7
8
        Add some checks to ensure that GraphicsContext (via QWebFrame)
9
        does not clobber the render hints.
10
11
        * Api/qwebview.cpp:
12
        (QWebViewPrivate::QWebViewPrivate):
13
        * tests/qwebframe/tst_qwebframe.cpp:
14
1
2010-12-15  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
15
2010-12-15  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
2
16
3
        Reviewed by Antonio Gomes.
17
        Reviewed by Antonio Gomes.
- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +135 lines
Lines 29-34 a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp_sec1
29
#include <QAbstractItemView>
29
#include <QAbstractItemView>
30
#include <QApplication>
30
#include <QApplication>
31
#include <QComboBox>
31
#include <QComboBox>
32
#include <QPaintEngine>
32
#include <QPicture>
33
#include <QPicture>
33
#include <QRegExp>
34
#include <QRegExp>
34
#include <QNetworkRequest>
35
#include <QNetworkRequest>
Lines 616-621 private slots: a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp_sec2
616
    void baseUrl();
617
    void baseUrl();
617
    void hasSetFocus();
618
    void hasSetFocus();
618
    void render();
619
    void render();
620
    void renderHints();
619
    void scrollPosition();
621
    void scrollPosition();
620
    void scrollToAnchor();
622
    void scrollToAnchor();
621
    void scrollbarsOff();
623
    void scrollbarsOff();
Lines 2857-2862 void tst_QWebFrame::render() a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp_sec3
2857
    QCOMPARE(size.height(), picture.boundingRect().height()); // height: 100px
2859
    QCOMPARE(size.height(), picture.boundingRect().height()); // height: 100px
2858
}
2860
}
2859
2861
2862
2863
class DummyPaintEngine: public QPaintEngine {
2864
public:
2865
2866
    DummyPaintEngine()
2867
        : QPaintEngine(QPaintEngine::AllFeatures)
2868
        , renderHints(0)
2869
    {
2870
    }
2871
2872
    bool begin(QPaintDevice*)
2873
    {
2874
        setActive(true);
2875
        return true;
2876
    }
2877
2878
    bool end()
2879
    {
2880
        setActive(false);
2881
        return false;
2882
    }
2883
2884
    void updateState(const QPaintEngineState& state)
2885
    {
2886
        renderHints = state.renderHints();
2887
    }
2888
2889
    void drawPath(const QPainterPath&) { }
2890
    void drawPixmap(const QRectF&, const QPixmap&, const QRectF&) { }
2891
2892
    QPaintEngine::Type type() const
2893
    {
2894
        return static_cast<QPaintEngine::Type>(QPaintEngine::User + 2);
2895
    }
2896
2897
    QPainter::RenderHints renderHints;
2898
};
2899
2900
class DummyPaintDevice: public QPaintDevice {
2901
public:
2902
    DummyPaintDevice()
2903
        : QPaintDevice()
2904
        , m_engine(new DummyPaintEngine)
2905
    {
2906
    }
2907
2908
    ~DummyPaintDevice()
2909
    {
2910
        delete m_engine;
2911
    }
2912
2913
    QPaintEngine* paintEngine() const
2914
    {
2915
        return m_engine;
2916
    }
2917
2918
    QPainter::RenderHints renderHints() const
2919
    {
2920
        return m_engine->renderHints;
2921
    }
2922
2923
protected:
2924
    int metric(PaintDeviceMetric metric) const;
2925
2926
private:
2927
    DummyPaintEngine* m_engine;
2928
    friend class DummyPaintEngine;
2929
};
2930
2931
2932
int DummyPaintDevice::metric(PaintDeviceMetric metric) const
2933
{
2934
    switch (metric) {
2935
    case PdmWidth:
2936
        return 400;
2937
        break;
2938
2939
    case PdmHeight:
2940
        return 200;
2941
        break;
2942
2943
    case PdmNumColors:
2944
        return INT_MAX;
2945
        break;
2946
2947
    case PdmDepth:
2948
        return 32;
2949
        break;
2950
2951
    default:
2952
        break;
2953
    }
2954
    return 0;
2955
}
2956
2957
void tst_QWebFrame::renderHints()
2958
{
2959
    QString html("<html><body><p>Hello, world!</p></body></html>");
2960
2961
    QWebPage page;
2962
    page.mainFrame()->setHtml(html);
2963
    page.setViewportSize(page.mainFrame()->contentsSize());
2964
2965
    // We will call frame->render and trap the paint engine state changes
2966
    // to ensure that GraphicsContext does not clobber the render hints.
2967
    DummyPaintDevice buffer;
2968
    QPainter painter(&buffer);
2969
2970
    painter.setRenderHint(QPainter::TextAntialiasing, false);
2971
    page.mainFrame()->render(&painter);
2972
    QVERIFY(!(buffer.renderHints() & QPainter::TextAntialiasing));
2973
    QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform));
2974
    QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing));
2975
2976
    painter.setRenderHint(QPainter::TextAntialiasing, true);
2977
    page.mainFrame()->render(&painter);
2978
    QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing);
2979
    QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform));
2980
    QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing));
2981
2982
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
2983
    page.mainFrame()->render(&painter);
2984
    QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing);
2985
    QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform);
2986
    QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing));
2987
2988
    painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
2989
    page.mainFrame()->render(&painter);
2990
    QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing);
2991
    QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform);
2992
    QVERIFY(buffer.renderHints() & QPainter::HighQualityAntialiasing);
2993
}
2994
2860
void tst_QWebFrame::scrollPosition()
2995
void tst_QWebFrame::scrollPosition()
2861
{
2996
{
2862
    // enlarged image in a small viewport, to provoke the scrollbars to appear
2997
    // enlarged image in a small viewport, to provoke the scrollbars to appear

Return to Bug 51208