Changeset 91985 in webkit


Ignore:
Timestamp:
Jul 29, 2011 4:55:06 AM (13 years ago)
Author:
alexis.menard@openbossa.org
Message:

[Qt] Make QDesktopWebView/QTouchWebView loadProgress property more usable in QML.
https://bugs.webkit.org/show_bug.cgi?id=65315

Reviewed by Benjamin Poulain.

In order to use the loadProgress value in QML we need to make it
a Q_PROPERTY, therefore we need a getter to get it.

  • UIProcess/API/qt/qdesktopwebview.cpp:

(QDesktopWebViewPrivate::didChangeLoadProgress):
(QDesktopWebView::url):
(QDesktopWebView::loadProgress):

  • UIProcess/API/qt/qdesktopwebview.h:
  • UIProcess/API/qt/qtouchwebpage.cpp:

(QTouchWebPage::loadProgress):

  • UIProcess/API/qt/qtouchwebpage.h:
  • UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:

(tst_CommonViewTests::stop):
(tst_CommonViewTests::loadProgress):

  • UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:

(WebViewAbstraction::WebViewAbstraction):
(WebViewAbstraction::loadProgress):
(WebViewAbstraction::desktopViewLoadFailed):
(WebViewAbstraction::touchViewLoadProgressChanged):
(WebViewAbstraction::desktopViewLoadProgressChanged):

  • UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h:
  • UIProcess/qt/QtWebPageProxy.cpp:

(QtWebPageProxy::QtWebPageProxy):
(QtWebPageProxy::didChangeLoadProgress):

  • UIProcess/qt/QtWebPageProxy.h:

(QtWebPageProxy::loadProgress):

  • UIProcess/qt/TouchViewInterface.cpp:

(WebKit::TouchViewInterface::didChangeLoadProgress):

Location:
trunk/Source/WebKit2
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r91979 r91985  
     12011-07-29  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        [Qt] Make QDesktopWebView/QTouchWebView loadProgress property more usable in QML.
     4        https://bugs.webkit.org/show_bug.cgi?id=65315
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        In order to use the loadProgress value in QML we need to make it
     9        a Q_PROPERTY, therefore we need a getter to get it.
     10
     11        * UIProcess/API/qt/qdesktopwebview.cpp:
     12        (QDesktopWebViewPrivate::didChangeLoadProgress):
     13        (QDesktopWebView::url):
     14        (QDesktopWebView::loadProgress):
     15        * UIProcess/API/qt/qdesktopwebview.h:
     16        * UIProcess/API/qt/qtouchwebpage.cpp:
     17        (QTouchWebPage::loadProgress):
     18        * UIProcess/API/qt/qtouchwebpage.h:
     19        * UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:
     20        (tst_CommonViewTests::stop):
     21        (tst_CommonViewTests::loadProgress):
     22        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:
     23        (WebViewAbstraction::WebViewAbstraction):
     24        (WebViewAbstraction::loadProgress):
     25        (WebViewAbstraction::desktopViewLoadFailed):
     26        (WebViewAbstraction::touchViewLoadProgressChanged):
     27        (WebViewAbstraction::desktopViewLoadProgressChanged):
     28        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h:
     29        * UIProcess/qt/QtWebPageProxy.cpp:
     30        (QtWebPageProxy::QtWebPageProxy):
     31        (QtWebPageProxy::didChangeLoadProgress):
     32        * UIProcess/qt/QtWebPageProxy.h:
     33        (QtWebPageProxy::loadProgress):
     34        * UIProcess/qt/TouchViewInterface.cpp:
     35        (WebKit::TouchViewInterface::didChangeLoadProgress):
     36
    1372011-07-27  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    238
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp

    r91863 r91985  
    133133void QDesktopWebViewPrivate::didChangeLoadProgress(int percentageLoaded)
    134134{
    135     emit q->loadProgress(percentageLoaded);
     135    emit q->loadProgressChanged(percentageLoaded);
    136136}
    137137
     
    197197{
    198198    return d->page.url();
     199}
     200
     201int QDesktopWebView::loadProgress() const
     202{
     203    return d->page.loadProgress();
    199204}
    200205
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h

    r91863 r91985  
    5252    Q_PROPERTY(QString title READ title NOTIFY titleChanged)
    5353    Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
     54    Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
    5455
    5556    Q_ENUMS(NavigationAction)
    5657
    5758public:
     59
    5860    QDesktopWebView(QSGItem* parent = 0);
    5961    virtual ~QDesktopWebView();
     
    6163    QUrl url() const;
    6264    QString title() const;
     65    int loadProgress() const;
    6366
    6467    Q_INVOKABLE QAction* navigationAction(QtWebKit::NavigationAction which) const;
     
    7376    void loadSucceeded();
    7477    void loadFailed(const QWebError&);
    75     void loadProgress(int progress);
     78    void loadProgressChanged(int progress);
    7679    void urlChanged(const QUrl&);
    7780
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp

    r91863 r91985  
    5959{
    6060    return d->page->title();
     61}
     62
     63int QTouchWebPage::loadProgress() const
     64{
     65    return d->page->loadProgress();
    6166}
    6267
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h

    r91863 r91985  
    4040    Q_PROPERTY(QString title READ title NOTIFY titleChanged)
    4141    Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
     42    Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
    4243
    4344public:
     
    5051
    5152    Q_INVOKABLE QString title() const;
     53    int loadProgress() const;
    5254
    5355    QAction* navigationAction(QtWebKit::NavigationAction which);
     
    6264    void loadSucceeded();
    6365    void loadFailed(const QWebError&);
    64     void loadProgress(int progress);
     66    void loadProgressChanged(int progress);
    6567
    6668protected:
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp

    r90820 r91985  
    3838    void reload();
    3939    void stop();
     40    void loadProgress();
    4041
    4142    void show();
     
    151152}
    152153
     154void tst_CommonViewTests::loadProgress()
     155{
     156    QCOMPARE(viewAbstraction->loadProgress(), 0);
     157
     158    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
     159    QSignalSpy loadProgressChangedSpy(viewAbstraction.data(), SIGNAL(loadProgressChanged(int)));
     160    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
     161
     162    QVERIFY(loadProgressChangedSpy.count() >= 1);
     163
     164    QCOMPARE(viewAbstraction->loadProgress(), 100);
     165}
     166
    153167void tst_CommonViewTests::show()
    154168{
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp

    r90820 r91985  
    3636    connect(touchWebView()->page(), SIGNAL(loadSucceeded()), this, SLOT(touchViewLoadSucceeded()));
    3737    connect(touchWebView()->page(), SIGNAL(loadFailed(QWebError)), this, SLOT(touchViewLoadFailed(QWebError)));
     38    connect(touchWebView()->page(), SIGNAL(loadProgressChanged(int)), this, SLOT(touchViewLoadProgressChanged(int)));
    3839
    3940    screenHalf.moveLeft(screenHalf.right());
     
    4344    connect(desktopWebView(), SIGNAL(loadSucceeded()), this, SLOT(desktopViewLoadSucceeded()));
    4445    connect(desktopWebView(), SIGNAL(loadFailed(QWebError)), this, SLOT(desktopViewLoadFailed(QWebError)));
     46    connect(desktopWebView(), SIGNAL(loadProgressChanged(int)), this, SLOT(desktopViewLoadProgressChanged(int)));
    4547}
    4648
     
    7880    url = touchViewUrl;
    7981    return true;
     82}
     83
     84int WebViewAbstraction::loadProgress() const
     85{
     86    int touchViewProgress = touchWebView()->page()->loadProgress();
     87    int desktopViewProgress = desktopWebView()->loadProgress();
     88
     89    if (touchViewProgress != desktopViewProgress) {
     90        qWarning() << "WebViewAbstraction::loadProgress(): the load progress are different.";
     91        qWarning() << "QTouchView's load progress = " << touchViewProgress;
     92        qWarning() << "QDesktopView's load progress = " << desktopViewProgress;
     93        return -1;
     94    }
     95
     96    return touchViewProgress;
    8097}
    8198
     
    130147}
    131148
     149void WebViewAbstraction::touchViewLoadProgressChanged(int progress)
     150{
     151    m_touchViewSignalsCounter[SIGNAL(loadProgressChanged(int))]++;
     152    if (m_touchViewSignalsCounter[SIGNAL(loadProgressChanged(int))] == m_desktopViewSignalsCounter[SIGNAL(loadProgressChanged(int))])
     153        emit loadProgressChanged(progress);
     154}
     155
     156void WebViewAbstraction::desktopViewLoadProgressChanged(int progress)
     157{
     158    m_desktopViewSignalsCounter[SIGNAL(loadProgressChanged(int))]++;
     159    if (m_touchViewSignalsCounter[SIGNAL(loadProgressChanged(int))] == m_desktopViewSignalsCounter[SIGNAL(loadProgressChanged(int))])
     160        emit loadProgressChanged(progress);
     161}
     162
    132163QTouchWebView* WebViewAbstraction::touchWebView() const
    133164{
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h

    r90820 r91985  
    4040    void load(const QUrl&);
    4141    bool url(QUrl&) const;
     42    int loadProgress() const;
    4243
    4344    void triggerNavigationAction(QtWebKit::NavigationAction);
     
    4748    void loadSucceeded();
    4849    void loadFailed(const QWebError&);
     50    void loadProgressChanged(int);
    4951
    5052private Q_SLOTS:
     
    5557    void touchViewLoadFailed(const QWebError&);
    5658    void desktopViewLoadFailed(const QWebError&);
     59    void touchViewLoadProgressChanged(int);
     60    void desktopViewLoadProgressChanged(int);
    5761
    5862private:
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r91840 r91985  
    100100    , m_preferences(0)
    101101    , m_undoStack(adoptPtr(new QUndoStack(this)))
     102    , m_loadProgress(0)
    102103{
    103104    ASSERT(viewInterface);
     
    427428void QtWebPageProxy::didChangeLoadProgress(int newLoadProgress)
    428429{
     430    m_loadProgress = newLoadProgress;
    429431    m_viewInterface->didChangeLoadProgress(newLoadProgress);
    430432}
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r91831 r91985  
    135135    void loadDidFail(const QWebError&);
    136136    void didChangeLoadProgress(int);
     137    int loadProgress() const { return m_loadProgress; }
    137138
    138139    void paint(QPainter* painter, QRect);
     
    198199
    199200    OwnPtr<QUndoStack> m_undoStack;
     201    int m_loadProgress;
    200202};
    201203
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp

    r91863 r91985  
    178178void TouchViewInterface::didChangeLoadProgress(int percentageLoaded)
    179179{
    180     emit m_pageView->loadProgress(percentageLoaded);
     180    emit m_pageView->loadProgressChanged(percentageLoaded);
    181181}
    182182
Note: See TracChangeset for help on using the changeset viewer.