Changeset 80774 in webkit
- Timestamp:
- Mar 10, 2011 3:36:38 PM (13 years ago)
- Location:
- trunk/Source/WebKit/qt
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/qt/ChangeLog
r80769 r80774 1 2011-03-10 Alexis Menard <alexis.menard@openbossa.org> 2 3 Reviewed by Andreas Kling. 4 5 [Qt] QtDeclarative Webview element has a fixed white background 6 https://bugs.webkit.org/show_bug.cgi?id=40918 7 8 Implement a way to change the background color of the WebView QML element. 9 This feature is activated for QtWebKit 1.1 version of the plugin. 10 11 * declarative/plugin.cpp: 12 (WebKitQmlPlugin::registerTypes): 13 * declarative/qdeclarativewebview.cpp: 14 (QDeclarativeWebView::backgroundColor): 15 (QDeclarativeWebView::setBackgroundColor): 16 * declarative/qdeclarativewebview_p.h: 17 * tests/qdeclarativewebview/resources/webviewbackgroundcolor.qml: Added. 18 * tests/qdeclarativewebview/tst_qdeclarativewebview.cpp: 19 (tst_QDeclarativeWebView::backgroundColor): 20 * tests/qdeclarativewebview/tst_qdeclarativewebview.qrc: 21 1 22 2011-03-10 Stanislav Paltis <Stanislav.Paltis@nokia.com> 2 23 -
trunk/Source/WebKit/qt/declarative/plugin.cpp
r61325 r80774 33 33 qmlRegisterType<QDeclarativeWebSettings>(); 34 34 qmlRegisterType<QDeclarativeWebView>(uri, 1, 0, "WebView"); 35 #if QT_VERSION >= 0x040702 36 qmlRegisterType<QDeclarativeWebView>(uri, 1, 1, "WebView"); 37 qmlRegisterRevision<QDeclarativeWebView, 0>("QtWebKit", 1, 0); 38 qmlRegisterRevision<QDeclarativeWebView, 1>("QtWebKit", 1, 1); 39 #endif 35 40 } 36 41 }; -
trunk/Source/WebKit/qt/declarative/qdeclarativewebview.cpp
r79672 r80774 984 984 } 985 985 986 #if QT_VERSION >= 0x040702 987 /*! 988 \qmlproperty color WebView::backgroundColor 989 \since QtWebKit 1.1 990 This property holds the background color of the view. 991 */ 992 993 QColor QDeclarativeWebView::backgroundColor() const 994 { 995 return d->view->palette().base().color(); 996 } 997 998 void QDeclarativeWebView::setBackgroundColor(const QColor& color) 999 { 1000 QPalette palette = d->view->palette(); 1001 if (palette.base().color() == color) 1002 return; 1003 palette.setBrush(QPalette::Base, color); 1004 d->view->setPalette(palette); 1005 emit backgroundColorChanged(); 1006 } 1007 #endif 1008 986 1009 /*! 987 1010 Returns the area of the largest element at position (\a x,\a y) that is no larger -
trunk/Source/WebKit/qt/declarative/qdeclarativewebview_p.h
r78270 r80774 124 124 Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeChanged) 125 125 Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) 126 #if QT_VERSION >= 0x040702 127 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged REVISION 1) 128 #endif 126 129 127 130 public: … … 193 196 void setContentsScale(qreal scale); 194 197 qreal contentsScale() const; 198 199 #if QT_VERSION >= 0x040702 200 Q_REVISION(1) QColor backgroundColor() const; 201 Q_REVISION(1) void setBackgroundColor(const QColor&); 202 #endif 195 203 196 204 Q_SIGNALS: … … 210 218 void contentsSizeChanged(const QSize&); 211 219 void contentsScaleChanged(); 220 #if QT_VERSION >= 0x040702 221 void backgroundColorChanged(); 222 #endif 212 223 213 224 void loadStarted(); -
trunk/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp
r79894 r80774 1 1 #include "../util.h" 2 #include <QColor> 2 3 #include <QDebug> 3 4 #include <QDeclarativeComponent> … … 23 24 void preferredWidthDefaultTest(); 24 25 void preferredHeightDefaultTest(); 26 #if QT_VERSION >= 0x040702 27 void backgroundColor(); 28 #endif 25 29 26 30 private: … … 83 87 } 84 88 89 #if QT_VERSION >= 0x040702 90 void tst_QDeclarativeWebView::backgroundColor() 91 { 92 // We test here the rendering of the background. 93 QDeclarativeEngine engine; 94 QDeclarativeComponent component(&engine, QUrl("qrc:///resources/webviewbackgroundcolor.qml")); 95 checkNoErrors(component); 96 QObject* wv = component.create(); 97 QVERIFY(wv); 98 QCOMPARE(wv->property("backgroundColor").value<QColor>(), QColor(Qt::red)); 99 QDeclarativeView view; 100 view.setSource(QUrl("qrc:///resources/webviewbackgroundcolor.qml")); 101 view.show(); 102 QTest::qWaitForWindowShown(&view); 103 QPixmap result(view.width(), view.height()); 104 QPainter painter(&result); 105 view.render(&painter); 106 QPixmap reference(view.width(), view.height()); 107 reference.fill(Qt::red); 108 QCOMPARE(reference, result); 109 110 // We test the emission of the backgroundColorChanged signal. 111 QSignalSpy spyColorChanged(wv, SIGNAL(backgroundColorChanged())); 112 wv->setProperty("backgroundColor", Qt::red); 113 QCOMPARE(spyColorChanged.count(), 0); 114 wv->setProperty("backgroundColor", Qt::green); 115 QCOMPARE(spyColorChanged.count(), 1); 116 } 117 #endif 118 85 119 void tst_QDeclarativeWebView::checkNoErrors(const QDeclarativeComponent& component) 86 120 { -
trunk/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.qrc
r79894 r80774 4 4 <file>resources/webviewtest.qml</file> 5 5 <file>resources/sample.html</file> 6 <file>resources/webviewbackgroundcolor.qml</file> 6 7 </qresource> 7 8 </RCC>
Note: See TracChangeset
for help on using the changeset viewer.