|
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 |