Changeset 148095 in webkit
- Timestamp:
- Apr 10, 2013 8:10:08 AM (11 years ago)
- Location:
- trunk/Source/WebKit/qt
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/qt/Api/qwebsettings.cpp
r147637 r148095 80 80 QString localStoragePath; 81 81 QString offlineWebApplicationCachePath; 82 QString mediaType; 82 83 qint64 offlineStorageDefaultQuota; 83 84 QWebSettings::ThirdPartyCookiePolicy thirdPartyCookiePolicy; … … 238 239 QString storagePath = !localStoragePath.isEmpty() ? localStoragePath : global->localStoragePath; 239 240 settings->setLocalStorageDatabasePath(storagePath); 241 242 if (mediaType.isEmpty()) 243 mediaType = global->mediaType; 240 244 241 245 value = attributes.value(QWebSettings::PrintElementBackgrounds, … … 932 936 933 937 /*! 938 Sets the CSS media type to \a type. 939 940 Setting this will override the normal value of the CSS media property. 941 942 \note Setting the value to null QString will restore the default value. 943 */ 944 void QWebSettings::setCSSMediaType(const QString& type) 945 { 946 d->mediaType = type; 947 d->apply(); 948 } 949 950 /*! 951 Returns the current CSS media type. 952 953 \note It will only return the value set through setCSSMediaType and not the one used internally. 954 */ 955 QString QWebSettings::cssMediaType() const 956 { 957 return d->mediaType; 958 } 959 960 /*! 934 961 Sets the actual font family to \a family for the specified generic family, 935 962 \a which. -
trunk/Source/WebKit/qt/Api/qwebsettings.h
r145833 r148095 165 165 QWebSettings::ThirdPartyCookiePolicy thirdPartyCookiePolicy() const; 166 166 167 void setCSSMediaType(const QString&); 168 QString cssMediaType() const; 169 167 170 inline QWebSettingsPrivate* handle() const { return d; } 168 171 -
trunk/Source/WebKit/qt/ChangeLog
r148022 r148095 1 2013-04-10 Jose Lejin PJ <jose.lejin@gmail.com> 2 3 [Qt] Add API in QWebSettings for setting the CSS media type 4 https://bugs.webkit.org/show_bug.cgi?id=113853 5 6 Reviewed by Jocelyn Turcotte. 7 8 * Api/qwebsettings.cpp: 9 (QWebSettingsPrivate): 10 (QWebSettingsPrivate::apply): 11 (QWebSettings::setCSSMediaType): 12 (QWebSettings::cssMediaType): 13 * Api/qwebsettings.h: 14 * WebCoreSupport/FrameLoaderClientQt.cpp: 15 (WebCore::FrameLoaderClientQt::overrideMediaType): 16 * tests/qwebpage/tst_qwebpage.cpp: 17 (tst_QWebPage): 18 (tst_QWebPage::cssMediaTypeGlobalSetting): 19 (tst_QWebPage::cssMediaTypePageSetting): 20 1 21 2013-04-09 Rafael Brandao <rafael.lobo@openbossa.org> 2 22 -
trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
r145914 r148095 79 79 #include "qwebhistoryinterface.h" 80 80 #include "qwebpluginfactory.h" 81 #include "qwebsettings.h" 81 82 82 83 #include <QCoreApplication> … … 1564 1565 String FrameLoaderClientQt::overrideMediaType() const 1565 1566 { 1567 if (m_webFrame && m_webFrame->pageAdapter && m_webFrame->pageAdapter->settings) 1568 return m_webFrame->pageAdapter->settings->cssMediaType(); 1569 1566 1570 return String(); 1567 1571 } -
trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
r142755 r148095 188 188 void loadSignalsOrder(); 189 189 void openWindowDefaultSize(); 190 void cssMediaTypeGlobalSetting(); 191 void cssMediaTypePageSetting(); 190 192 191 193 #ifdef Q_OS_MAC … … 3287 3289 } 3288 3290 3291 void tst_QWebPage::cssMediaTypeGlobalSetting() 3292 { 3293 QString testHtml("<style>@media tv {body{background-color:red;}}@media handheld {body{background-color:green;}}@media screen {body{background-color:blue;}}</style>"); 3294 QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); 3295 3296 QWebSettings::globalSettings()->setCSSMediaType("tv"); 3297 // Clear page specific setting to read from global setting 3298 m_view->page()->settings()->setCSSMediaType(QString()); 3299 m_view->setHtml(testHtml); 3300 QTRY_COMPARE(loadSpy.count(), 1); 3301 QVERIFY(m_view->page()->mainFrame()->evaluateJavaScript("window.matchMedia('tv').matches == true").toBool()); 3302 QVERIFY(QWebSettings::globalSettings()->cssMediaType() == "tv"); 3303 3304 QWebSettings::globalSettings()->setCSSMediaType("handheld"); 3305 // Clear page specific setting to read from global setting 3306 m_view->page()->settings()->setCSSMediaType(QString()); 3307 m_view->setHtml(testHtml); 3308 QTRY_COMPARE(loadSpy.count(), 2); 3309 QVERIFY(m_view->page()->mainFrame()->evaluateJavaScript("window.matchMedia('handheld').matches == true").toBool()); 3310 QVERIFY(QWebSettings::globalSettings()->cssMediaType() == "handheld"); 3311 3312 QWebSettings::globalSettings()->setCSSMediaType("screen"); 3313 // Clear page specific setting to read from global setting 3314 m_view->page()->settings()->setCSSMediaType(QString()); 3315 m_view->setHtml(testHtml); 3316 QTRY_COMPARE(loadSpy.count(), 3); 3317 QVERIFY(m_view->page()->mainFrame()->evaluateJavaScript("window.matchMedia('screen').matches == true").toBool()); 3318 QVERIFY(QWebSettings::globalSettings()->cssMediaType() == "screen"); 3319 } 3320 3321 void tst_QWebPage::cssMediaTypePageSetting() 3322 { 3323 QString testHtml("<style>@media tv {body{background-color:red;}}@media handheld {body{background-color:green;}}@media screen {body{background-color:blue;}}</style>"); 3324 QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); 3325 3326 m_view->page()->settings()->setCSSMediaType("tv"); 3327 m_view->setHtml(testHtml); 3328 QTRY_COMPARE(loadSpy.count(), 1); 3329 QVERIFY(m_view->page()->mainFrame()->evaluateJavaScript("window.matchMedia('tv').matches == true").toBool()); 3330 QVERIFY(m_view->page()->settings()->cssMediaType() == "tv"); 3331 3332 m_view->page()->settings()->setCSSMediaType("handheld"); 3333 m_view->setHtml(testHtml); 3334 QTRY_COMPARE(loadSpy.count(), 2); 3335 QVERIFY(m_view->page()->mainFrame()->evaluateJavaScript("window.matchMedia('handheld').matches == true").toBool()); 3336 QVERIFY(m_view->page()->settings()->cssMediaType() == "handheld"); 3337 3338 m_view->page()->settings()->setCSSMediaType("screen"); 3339 m_view->setHtml(testHtml); 3340 QTRY_COMPARE(loadSpy.count(), 3); 3341 QVERIFY(m_view->page()->mainFrame()->evaluateJavaScript("window.matchMedia('screen').matches == true").toBool()); 3342 QVERIFY(m_view->page()->settings()->cssMediaType() == "screen"); 3343 } 3344 3289 3345 QTEST_MAIN(tst_QWebPage) 3290 3346 #include "tst_qwebpage.moc"
Note: See TracChangeset
for help on using the changeset viewer.