Changeset 98447 in webkit


Ignore:
Timestamp:
Oct 26, 2011 1:28:30 AM (12 years ago)
Author:
Simon Hausmann
Message:

[Qt][WK2] Remove QAction from MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=70525

In order to rewrite MiniBrowser in QML we need a suitable
mechanism for triggering navigation actions.
Due to the QtWidgets dependency of QAction the current
solution is not suitable anymore. Therefore we introduce
invokable methods and export properties in QWebNavigationController.

Patch by Jocelyn Turcotte <jocelyn.turcotte@nokia.com>,

Zeno Albisser <zeno.albisser@nokia.com>

Patch by Zeno Albisser <zeno.albisser@nokia.com> on 2011-10-25
Reviewed by Simon Hausmann.

Source/WebKit2:

  • UIProcess/API/qt/WKView.h:
  • UIProcess/API/qt/qdesktopwebview.h:
  • UIProcess/API/qt/qtouchwebpage.h:
  • UIProcess/API/qt/qwebkittypes.h: Removed.
  • UIProcess/API/qt/qwebnavigationcontroller.cpp:

(QWebNavigationController::QWebNavigationController):
(QWebNavigationController::canGoBack):
(QWebNavigationController::canGoForward):
(QWebNavigationController::canStop):
(QWebNavigationController::canReload):
(QWebNavigationController::goBack):
(QWebNavigationController::goForward):
(QWebNavigationController::stop):
(QWebNavigationController::reload):

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

(tst_CommonViewTests::backAndForward):
(tst_CommonViewTests::reload):
(tst_CommonViewTests::stop):

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

(WebViewAbstraction::goBack):
(WebViewAbstraction::goForward):
(WebViewAbstraction::stop):
(WebViewAbstraction::reload):

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

(tst_QDesktopWebView::navigationStatusAtStartup):
(LoadStartedCatcher::onLoadStarted):
(tst_QDesktopWebView::stopEnabledAfterLoadStarted):

  • UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp:

(tst_QTouchWebView::navigationStatusAtStartup):

  • UIProcess/qt/ClientImpl.cpp:

(dispatchLoadSucceeded):
(dispatchLoadFailed):
(qt_wk_didStartProvisionalLoadForFrame):
(qt_wk_didCommitLoadForFrame):
(qt_wk_didSameDocumentNavigationForFrame):

  • UIProcess/qt/QtWebPageProxy.cpp:

(QtWebPageProxy::QtWebPageProxy):
(QtWebPageProxy::canGoBack):
(QtWebPageProxy::goBack):
(QtWebPageProxy::canGoForward):
(QtWebPageProxy::goForward):
(QtWebPageProxy::canStop):
(QtWebPageProxy::stop):
(QtWebPageProxy::canReload):
(QtWebPageProxy::reload):
(QtWebPageProxy::navigationStateChanged):
(QtWebPageProxy::didRelaunchProcess):
(QtWebPageProxy::processDidCrash):

  • UIProcess/qt/QtWebPageProxy.h:
  • WebKit2API.pri:

Tools:

  • MiniBrowser/qt/BrowserView.cpp:
  • MiniBrowser/qt/BrowserView.h:
  • MiniBrowser/qt/BrowserWindow.cpp:

(BrowserWindow::BrowserWindow):

Location:
trunk
Files:
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r98438 r98447  
     12011-10-25  Zeno Albisser  <zeno.albisser@nokia.com>
     2
     3        [Qt][WK2] Remove QAction from MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=70525
     5
     6        In order to rewrite MiniBrowser in QML we need a suitable
     7        mechanism for triggering navigation actions.
     8        Due to the QtWidgets dependency of QAction the current
     9        solution is not suitable anymore. Therefore we introduce
     10        invokable methods and export properties in QWebNavigationController.
     11
     12        Patch by Jocelyn Turcotte <jocelyn.turcotte@nokia.com>,
     13                 Zeno Albisser <zeno.albisser@nokia.com>
     14
     15        Reviewed by Simon Hausmann.
     16
     17        * UIProcess/API/qt/WKView.h:
     18        * UIProcess/API/qt/qdesktopwebview.h:
     19        * UIProcess/API/qt/qtouchwebpage.h:
     20        * UIProcess/API/qt/qwebkittypes.h: Removed.
     21        * UIProcess/API/qt/qwebnavigationcontroller.cpp:
     22        (QWebNavigationController::QWebNavigationController):
     23        (QWebNavigationController::canGoBack):
     24        (QWebNavigationController::canGoForward):
     25        (QWebNavigationController::canStop):
     26        (QWebNavigationController::canReload):
     27        (QWebNavigationController::goBack):
     28        (QWebNavigationController::goForward):
     29        (QWebNavigationController::stop):
     30        (QWebNavigationController::reload):
     31        * UIProcess/API/qt/qwebnavigationcontroller.h:
     32        * UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:
     33        (tst_CommonViewTests::backAndForward):
     34        (tst_CommonViewTests::reload):
     35        (tst_CommonViewTests::stop):
     36        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:
     37        (WebViewAbstraction::goBack):
     38        (WebViewAbstraction::goForward):
     39        (WebViewAbstraction::stop):
     40        (WebViewAbstraction::reload):
     41        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h:
     42        * UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp:
     43        (tst_QDesktopWebView::navigationStatusAtStartup):
     44        (LoadStartedCatcher::onLoadStarted):
     45        (tst_QDesktopWebView::stopEnabledAfterLoadStarted):
     46        * UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp:
     47        (tst_QTouchWebView::navigationStatusAtStartup):
     48        * UIProcess/qt/ClientImpl.cpp:
     49        (dispatchLoadSucceeded):
     50        (dispatchLoadFailed):
     51        (qt_wk_didStartProvisionalLoadForFrame):
     52        (qt_wk_didCommitLoadForFrame):
     53        (qt_wk_didSameDocumentNavigationForFrame):
     54        * UIProcess/qt/QtWebPageProxy.cpp:
     55        (QtWebPageProxy::QtWebPageProxy):
     56        (QtWebPageProxy::canGoBack):
     57        (QtWebPageProxy::goBack):
     58        (QtWebPageProxy::canGoForward):
     59        (QtWebPageProxy::goForward):
     60        (QtWebPageProxy::canStop):
     61        (QtWebPageProxy::stop):
     62        (QtWebPageProxy::canReload):
     63        (QtWebPageProxy::reload):
     64        (QtWebPageProxy::navigationStateChanged):
     65        (QtWebPageProxy::didRelaunchProcess):
     66        (QtWebPageProxy::processDidCrash):
     67        * UIProcess/qt/QtWebPageProxy.h:
     68        * WebKit2API.pri:
     69
    1702011-10-26  Ryosuke Niwa  <rniwa@webkit.org>
    271
  • trunk/Source/WebKit2/UIProcess/API/qt/WKView.h

    r97740 r98447  
    2121#define WKView_h
    2222
    23 #include <WebKit2/qwebkittypes.h>
    2423#include <WebKit2/qdesktopwebview.h>
    2524#include <WebKit2/qtouchwebview.h>
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h

    r98337 r98447  
    2323
    2424#include "qwebkitglobal.h"
    25 #include "qwebkittypes.h"
    2625#include <QUrl>
    2726#include <QtDeclarative/qsgpainteditem.h>
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h

    r98332 r98447  
    2323
    2424#include "qwebkitglobal.h"
    25 #include "qwebkittypes.h"
    2625
    2726#include <QtDeclarative/qsgitem.h>
  • trunk/Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.cpp

    r95901 r98447  
    2424
    2525#include "QtWebPageProxy.h"
    26 #include "qwebkittypes.h"
    2726
    2827class QWebNavigationControllerPrivate {
     
    4140    , d(new QWebNavigationControllerPrivate(pageProxy))
    4241{
     42    connect(pageProxy, SIGNAL(updateNavigationState()), this, SIGNAL(navigationStateChanged()));
    4343}
    4444
     
    4848}
    4949
    50 QAction* QWebNavigationController::backAction() const
     50bool QWebNavigationController::canGoBack() const
    5151{
    52     return d->pageProxy->navigationAction(QtWebKit::Back);
     52    return d->pageProxy->canGoBack();
    5353}
    5454
    55 QAction* QWebNavigationController::forwardAction() const
     55bool QWebNavigationController::canGoForward() const
    5656{
    57     return d->pageProxy->navigationAction(QtWebKit::Forward);
     57    return d->pageProxy->canGoForward();
    5858}
    5959
    60 QAction* QWebNavigationController::stopAction() const
     60bool QWebNavigationController::canStop() const
    6161{
    62     return d->pageProxy->navigationAction(QtWebKit::Stop);
     62    return d->pageProxy->canStop();
    6363}
    6464
    65 QAction* QWebNavigationController::reloadAction() const
     65bool QWebNavigationController::canReload() const
    6666{
    67     return d->pageProxy->navigationAction(QtWebKit::Reload);
     67    return d->pageProxy->canReload();
    6868}
    6969
    70 QAction* QWebNavigationController::navigationAction(QtWebKit::NavigationAction which) const
     70void QWebNavigationController::goBack()
    7171{
    72     return d->pageProxy->navigationAction(which);
     72    d->pageProxy->goBack();
    7373}
    7474
    75 void QWebNavigationController::back()
     75void QWebNavigationController::goForward()
    7676{
    77     d->pageProxy->navigationAction(QtWebKit::Back)->trigger();
    78 }
    79 
    80 void QWebNavigationController::forward()
    81 {
    82     d->pageProxy->navigationAction(QtWebKit::Forward)->trigger();
     77    d->pageProxy->goForward();
    8378}
    8479
    8580void QWebNavigationController::stop()
    8681{
    87     d->pageProxy->navigationAction(QtWebKit::Stop)->trigger();
     82    d->pageProxy->stop();
    8883}
    8984
    9085void QWebNavigationController::reload()
    9186{
    92     d->pageProxy->navigationAction(QtWebKit::Reload)->trigger();
     87    d->pageProxy->reload();
    9388}
  • trunk/Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.h

    r96079 r98447  
    2424
    2525#include "qwebkitglobal.h"
    26 #include "qwebkittypes.h"
    2726#include <QtCore/QObject>
    2827
     
    3635class QWEBKIT_EXPORT QWebNavigationController : public QObject {
    3736    Q_OBJECT
    38     Q_PROPERTY(QAction* backAction READ backAction CONSTANT FINAL)
    39     Q_PROPERTY(QAction* forwardAction READ forwardAction CONSTANT FINAL)
    40     Q_PROPERTY(QAction* stopAction READ stopAction CONSTANT FINAL)
    41     Q_PROPERTY(QAction* reloadAction READ reloadAction CONSTANT FINAL)
     37    Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY navigationStateChanged FINAL)
     38    Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY navigationStateChanged FINAL)
     39    Q_PROPERTY(bool canStop READ canStop NOTIFY navigationStateChanged FINAL)
     40    Q_PROPERTY(bool canReload READ canReload NOTIFY navigationStateChanged FINAL)
    4241public:
    4342    QWebNavigationController(QtWebPageProxy*);
    4443    ~QWebNavigationController();
    4544
    46     QAction* backAction() const;
    47     QAction* forwardAction() const;
    48     QAction* stopAction() const;
    49     QAction* reloadAction() const;
    50 
    51     QAction* navigationAction(QtWebKit::NavigationAction which) const;
     45    bool canGoBack() const;
     46    bool canGoForward() const;
     47    bool canStop() const;
     48    bool canReload() const;
    5249
    5350public slots:
    54     void back();
    55     void forward();
     51    void goBack();
     52    void goForward();
    5653    void stop();
    5754    void reload();
     55
     56Q_SIGNALS:
     57    void navigationStateChanged();
    5858
    5959private:
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp

    r95901 r98447  
    118118    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"));
    119119
    120     viewAbstraction->triggerNavigationAction(QtWebKit::Back);
     120    viewAbstraction->goBack();
    121121    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
    122122
     
    124124    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
    125125
    126     viewAbstraction->triggerNavigationAction(QtWebKit::Forward);
     126    viewAbstraction->goForward();
    127127    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
    128128
     
    140140    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
    141141
    142     viewAbstraction->triggerNavigationAction(QtWebKit::Reload);
     142    viewAbstraction->reload();
    143143    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
    144144
     
    157157
    158158    // FIXME: This test should be fleshed out. Right now it's just here to make sure we don't crash.
    159     viewAbstraction->triggerNavigationAction(QtWebKit::Stop);
     159    viewAbstraction->stop();
    160160}
    161161
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp

    r95901 r98447  
    9898}
    9999
    100 void WebViewAbstraction::triggerNavigationAction(QtWebKit::NavigationAction which)
     100void WebViewAbstraction::goBack()
    101101{
    102     QAction* touchAction = touchWebView()->page()->navigationController()->navigationAction(which);
    103     touchAction->trigger();
    104     QAction* desktopAction = desktopWebView()->navigationController()->navigationAction(which);
    105     desktopAction->trigger();
     102    touchWebView()->page()->navigationController()->goBack();
     103}
     104
     105void WebViewAbstraction::goForward()
     106{
     107    touchWebView()->page()->navigationController()->goForward();
     108}
     109
     110void WebViewAbstraction::stop()
     111{
     112    touchWebView()->page()->navigationController()->stop();
     113}
     114
     115void WebViewAbstraction::reload()
     116{
     117    touchWebView()->page()->navigationController()->reload();
    106118}
    107119
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h

    r95901 r98447  
    4242    int loadProgress() const;
    4343
    44     void triggerNavigationAction(QtWebKit::NavigationAction);
     44    void goBack();
     45    void goForward();
     46    void stop();
     47    void reload();
    4548
    4649Q_SIGNALS:
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp

    r95901 r98447  
    1818*/
    1919
    20 #include <QAction>
    2120#include <QScopedPointer>
    2221#include <QtTest/QtTest>
     
    3534    void cleanup();
    3635
    37     void navigationActionsStatusAtStartup();
    38     void stopActionEnabledAfterLoadStarted();
     36    void navigationStatusAtStartup();
     37    void stopEnabledAfterLoadStarted();
    3938
    4039private:
     
    6362}
    6463
    65 void tst_QDesktopWebView::navigationActionsStatusAtStartup()
     64void tst_QDesktopWebView::navigationStatusAtStartup()
    6665{
    67     QAction* backAction = webView()->navigationController()->backAction();
    68     QVERIFY(backAction);
    69     QCOMPARE(backAction->isEnabled(), false);
     66    QCOMPARE(webView()->navigationController()->canGoBack(), false);
    7067
    71     QAction* forwardAction = webView()->navigationController()->forwardAction();
    72     QVERIFY(forwardAction);
    73     QCOMPARE(forwardAction->isEnabled(), false);
     68    QCOMPARE(webView()->navigationController()->canGoForward(), false);
    7469
    75     QAction* stopAction = webView()->navigationController()->stopAction();
    76     QVERIFY(stopAction);
    77     QCOMPARE(stopAction->isEnabled(), false);
     70    QCOMPARE(webView()->navigationController()->canStop(), false);
    7871
    79     QAction* reloadAction = webView()->navigationController()->reloadAction();
    80     QVERIFY(reloadAction);
    81     QCOMPARE(reloadAction->isEnabled(), false);
     72    QCOMPARE(webView()->navigationController()->canReload(), false);
    8273}
    8374
     
    9687        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
    9788
    98         QAction* stopAction = m_webView->navigationController()->stopAction();
    99         QVERIFY(stopAction);
    100         QCOMPARE(stopAction->isEnabled(), true);
     89        QCOMPARE(m_webView->navigationController()->canStop(), true);
    10190    }
    10291
     
    10897};
    10998
    110 void tst_QDesktopWebView::stopActionEnabledAfterLoadStarted()
     99void tst_QDesktopWebView::stopEnabledAfterLoadStarted()
    111100{
    112     QAction* stopAction = webView()->navigationController()->stopAction();
    113     QVERIFY(stopAction);
    114     QCOMPARE(stopAction->isEnabled(), false);
     101    QCOMPARE(webView()->navigationController()->canStop(), false);
    115102
    116103    LoadStartedCatcher catcher(webView());
     
    118105    waitForSignal(&catcher, SIGNAL(finished()));
    119106
    120     QCOMPARE(stopAction->isEnabled(), true);
     107    QCOMPARE(webView()->navigationController()->canStop(), true);
    121108
    122109    waitForSignal(webView(), SIGNAL(loadSucceeded()));
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp

    r95901 r98447  
    1818*/
    1919
    20 #include <QAction>
    2120#include <QtTest/QtTest>
    2221#include <qtouchwebpage.h>
     
    3736
    3837    void accessPage();
    39     void navigationActionsStatusAtStartup();
     38    void navigationStatusAtStartup();
    4039
    4140private:
     
    7473}
    7574
    76 void tst_QTouchWebView::navigationActionsStatusAtStartup()
     75void tst_QTouchWebView::navigationStatusAtStartup()
    7776{
    78     QAction* backAction = webView()->page()->navigationController()->backAction();
    79     QVERIFY(backAction);
    80     QCOMPARE(backAction->isEnabled(), false);
     77    QCOMPARE(webView()->page()->navigationController()->canGoBack(), false);
    8178
    82     QAction* forwardAction = webView()->page()->navigationController()->forwardAction();
    83     QVERIFY(forwardAction);
    84     QCOMPARE(forwardAction->isEnabled(), false);
     79    QCOMPARE(webView()->page()->navigationController()->canGoForward(), false);
    8580
    86     QAction* stopAction = webView()->page()->navigationController()->stopAction();
    87     QVERIFY(stopAction);
    88     QCOMPARE(stopAction->isEnabled(), false);
     81    QCOMPARE(webView()->page()->navigationController()->canStop(), false);
    8982
    90     QAction* reloadAction = webView()->page()->navigationController()->reloadAction();
    91     QVERIFY(reloadAction);
    92     QCOMPARE(reloadAction->isEnabled(), false);
     83    QCOMPARE(webView()->page()->navigationController()->canReload(), false);
    9384}
    9485
  • trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp

    r98030 r98447  
    6464        return;
    6565
    66     toQtWebPageProxy(clientInfo)->updateNavigationActions();
     66    toQtWebPageProxy(clientInfo)->updateNavigationState();
    6767    toQtWebPageProxy(clientInfo)->loadDidSucceed();
    6868}
     
    7373        return;
    7474
    75     toQtWebPageProxy(clientInfo)->updateNavigationActions();
     75    toQtWebPageProxy(clientInfo)->updateNavigationState();
    7676
    7777    int errorCode = WKErrorGetErrorCode(error);
     
    8787        return;
    8888
    89     toQtWebPageProxy(clientInfo)->updateNavigationActions();
     89    toQtWebPageProxy(clientInfo)->updateNavigationState();
    9090    toQtWebPageProxy(clientInfo)->loadDidBegin();
    9191}
     
    103103    QString urlStr(wkframe->url());
    104104    QUrl qUrl = urlStr;
    105     toQtWebPageProxy(clientInfo)->updateNavigationActions();
     105    toQtWebPageProxy(clientInfo)->updateNavigationState();
    106106    toQtWebPageProxy(clientInfo)->didChangeUrl(qUrl);
    107107    toQtWebPageProxy(clientInfo)->loadDidCommit();
     
    123123    QString urlStr(wkframe->url());
    124124    QUrl qUrl = urlStr;
    125     toQtWebPageProxy(clientInfo)->updateNavigationActions();
     125    toQtWebPageProxy(clientInfo)->updateNavigationState();
    126126    toQtWebPageProxy(clientInfo)->didChangeUrl(qUrl);
    127127}
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r98332 r98447  
    4343#include "WKStringQt.h"
    4444#include "WKURLQt.h"
    45 #include <QAction>
    4645#include <QApplication>
    4746#include <QGraphicsSceneMouseEvent>
    4847#include <QJSEngine>
    4948#include <QMimeData>
    50 #include <QStyle>
    5149#include <QTouchEvent>
    5250#include <QUndoStack>
     
    112110{
    113111    ASSERT(viewInterface);
    114     memset(m_actions, 0, sizeof(m_actions));
    115112    m_webPageProxy = m_context->createWebPage(this, toImpl(pageGroupRef));
    116113    m_history = QWKHistoryPrivate::createHistory(this, m_webPageProxy->backForwardList());
     
    431428}
    432429
    433 void QtWebPageProxy::updateAction(QtWebPageProxy::WebAction action)
    434 {
    435     QAction* a = m_actions[action];
    436     if (!a)
    437         return;
    438 
     430bool QtWebPageProxy::canGoBack() const
     431{
     432    return m_webPageProxy->canGoBack();
     433}
     434
     435void QtWebPageProxy::goBack()
     436{
     437    m_webPageProxy->goBack();
     438}
     439
     440bool QtWebPageProxy::canGoForward() const
     441{
     442    return m_webPageProxy->canGoForward();
     443}
     444
     445void QtWebPageProxy::goForward()
     446{
     447    m_webPageProxy->goForward();
     448}
     449
     450bool QtWebPageProxy::canStop() const
     451{
    439452    RefPtr<WebKit::WebFrameProxy> mainFrame = m_webPageProxy->mainFrame();
    440 
    441     bool enabled = a->isEnabled();
    442 
    443     switch (action) {
    444     case QtWebPageProxy::Back:
    445         enabled = m_webPageProxy->canGoBack();
    446         break;
    447     case QtWebPageProxy::Forward:
    448         enabled = m_webPageProxy->canGoForward();
    449         break;
    450     case QtWebPageProxy::Stop:
    451         enabled = mainFrame && !(WebFrameProxy::LoadStateFinished == mainFrame->loadState());
    452         break;
    453     case QtWebPageProxy::Reload:
    454         if (mainFrame)
    455             enabled = (WebFrameProxy::LoadStateFinished == mainFrame->loadState());
    456         else
    457             enabled = m_webPageProxy->backForwardList()->currentItem();
    458         break;
    459     default:
    460         ASSERT_NOT_REACHED();
    461     }
    462 
    463     a->setEnabled(enabled);
    464 }
    465 
    466 void QtWebPageProxy::updateNavigationActions()
    467 {
    468     updateAction(QtWebPageProxy::Back);
    469     updateAction(QtWebPageProxy::Forward);
    470     updateAction(QtWebPageProxy::Stop);
    471     updateAction(QtWebPageProxy::Reload);
    472 }
    473 
    474 void QtWebPageProxy::webActionTriggered(bool checked)
    475 {
    476     QAction* a = qobject_cast<QAction*>(sender());
    477     if (!a)
    478         return;
    479     QtWebPageProxy::WebAction action = static_cast<QtWebPageProxy::WebAction>(a->data().toInt());
    480     triggerAction(action, checked);
     453    return mainFrame && !(WebFrameProxy::LoadStateFinished == mainFrame->loadState());
     454}
     455
     456void QtWebPageProxy::stop()
     457{
     458    m_webPageProxy->stopLoading();
     459}
     460
     461bool QtWebPageProxy::canReload() const
     462{
     463    RefPtr<WebKit::WebFrameProxy> mainFrame = m_webPageProxy->mainFrame();
     464    if (mainFrame)
     465        return (WebFrameProxy::LoadStateFinished == mainFrame->loadState());
     466    return m_webPageProxy->backForwardList()->currentItem();
     467}
     468
     469void QtWebPageProxy::reload()
     470{
     471    m_webPageProxy->reload(/* reloadFromOrigin */ true);
     472}
     473
     474void QtWebPageProxy::navigationStateChanged()
     475{
     476    emit updateNavigationState();
    481477}
    482478
    483479void QtWebPageProxy::didRelaunchProcess()
    484480{
    485     updateNavigationActions();
     481    updateNavigationState();
    486482    m_viewInterface->didRelaunchProcess();
    487483    setDrawingAreaSize(m_viewInterface->drawingAreaSize());
     
    490486void QtWebPageProxy::processDidCrash()
    491487{
    492     updateNavigationActions();
     488    updateNavigationState();
    493489    m_viewInterface->processDidCrash();
    494490}
     
    569565{
    570566    return m_history;
    571 }
    572 
    573 void QtWebPageProxy::triggerAction(WebAction webAction, bool)
    574 {
    575     switch (webAction) {
    576     case Back:
    577         m_webPageProxy->goBack();
    578         return;
    579     case Forward:
    580         m_webPageProxy->goForward();
    581         return;
    582     case Stop:
    583         m_webPageProxy->stopLoading();
    584         return;
    585     case Reload:
    586         m_webPageProxy->reload(/* reloadFromOrigin */ true);
    587         return;
    588     default:
    589         ASSERT_NOT_REACHED();
    590     }
    591 }
    592 
    593 QAction* QtWebPageProxy::navigationAction(QtWebKit::NavigationAction which) const
    594 {
    595     switch (which) {
    596     case QtWebKit::Back:
    597         return action(QtWebPageProxy::Back);
    598     case QtWebKit::Forward:
    599         return action(QtWebPageProxy::Forward);
    600     case QtWebKit::Reload:
    601         return action(QtWebPageProxy::Reload);
    602     case QtWebKit::Stop:
    603         return action(QtWebPageProxy::Stop);
    604     }
    605 
    606     return 0;
    607 }
    608 
    609 QAction* QtWebPageProxy::action(WebAction action) const
    610 {
    611     if (action == QtWebPageProxy::NoWebAction || action >= WebActionCount)
    612         return 0;
    613 
    614     if (m_actions[action])
    615         return m_actions[action];
    616 
    617     QString text;
    618     QIcon icon;
    619     QStyle* style = qobject_cast<QApplication*>(QCoreApplication::instance())->style();
    620     bool checkable = false;
    621     QtWebPageProxy* mutableSelf = const_cast<QtWebPageProxy*>(this);
    622 
    623     switch (action) {
    624     case Back:
    625         text = contextMenuItemTagGoBack();
    626         icon = style->standardIcon(QStyle::SP_ArrowBack);
    627         break;
    628     case Forward:
    629         text = contextMenuItemTagGoForward();
    630         icon = style->standardIcon(QStyle::SP_ArrowForward);
    631         break;
    632     case Stop:
    633         text = contextMenuItemTagStop();
    634         icon = style->standardIcon(QStyle::SP_BrowserStop);
    635         break;
    636     case Reload:
    637         text = contextMenuItemTagReload();
    638         icon = style->standardIcon(QStyle::SP_BrowserReload);
    639         break;
    640     case Undo: {
    641         QAction* undoAction = m_undoStack->createUndoAction(mutableSelf);
    642         m_actions[action] = undoAction;
    643         return undoAction;
    644     }
    645     case Redo: {
    646         QAction* redoAction = m_undoStack->createRedoAction(mutableSelf);
    647         m_actions[action] = redoAction;
    648         return redoAction;
    649     }
    650     default:
    651         ASSERT_NOT_REACHED();
    652         break;
    653     }
    654 
    655     if (text.isEmpty())
    656         return 0;
    657 
    658     QAction* a = new QAction(mutableSelf);
    659     a->setText(text);
    660     a->setData(action);
    661     a->setCheckable(checkable);
    662     a->setIcon(icon);
    663 
    664     connect(a, SIGNAL(triggered(bool)), this, SLOT(webActionTriggered(bool)));
    665 
    666     m_actions[action] = a;
    667     mutableSelf->updateAction(action);
    668     return a;
    669567}
    670568
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r98332 r98447  
    2626#include "QtPolicyInterface.h"
    2727#include "QtViewInterface.h"
    28 #include "qwebkittypes.h"
    2928#include "ShareableBitmap.h"
    3029#include "ViewportArguments.h"
     
    140139    void paint(QPainter*, const QRect&);
    141140
    142     void updateAction(QtWebPageProxy::WebAction action);
    143     void updateNavigationActions();
     141    bool canGoBack() const;
     142    void goBack();
     143    bool canGoForward() const;
     144    void goForward();
     145    bool canStop() const;
     146    void stop();
     147    bool canReload() const;
     148    void reload();
     149
    144150    void updateEditorActions();
    145151
     
    154160
    155161    QString title() const;
    156 
    157     QAction* navigationAction(QtWebKit::NavigationAction) const;
    158 
    159     QAction* action(WebAction action) const;
    160     void triggerAction(WebAction action, bool checked = false);
    161162
    162163    void setCustomUserAgent(const QString&);
     
    172173
    173174public Q_SLOTS:
    174     void webActionTriggered(bool checked);
     175    void navigationStateChanged();
    175176
    176177public:
    177178    Q_SIGNAL void scrollRequested(int dx, int dy);
    178179    Q_SIGNAL void zoomableAreaFound(const QRect&);
     180    Q_SIGNAL void updateNavigationState();
    179181
    180182protected:
     
    199201    QWKHistory* m_history;
    200202
    201     mutable QAction* m_actions[QtWebPageProxy::WebActionCount];
    202203    mutable QWebPreferences* m_preferences;
    203204
  • trunk/Source/WebKit2/WebKit2API.pri

    r97740 r98447  
    137137    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebview.h \
    138138    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebview_p.h \
    139     $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qwebkittypes.h \
    140139    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.h \
    141140    $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h \
  • trunk/Tools/ChangeLog

    r98444 r98447  
     12011-10-25  Zeno Albisser  <zeno.albisser@nokia.com>
     2
     3        [Qt][WK2] Remove QAction from MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=70525
     5
     6        In order to rewrite MiniBrowser in QML we need a suitable
     7        mechanism for triggering navigation actions.
     8        Due to the QtWidgets dependency of QAction the current
     9        solution is not suitable anymore. Therefore we introduce
     10        invokable methods and export properties in QWebNavigationController.
     11
     12        Patch by Jocelyn Turcotte <jocelyn.turcotte@nokia.com>,
     13                 Zeno Albisser <zeno.albisser@nokia.com>
     14
     15        Reviewed by Simon Hausmann.
     16
     17        * MiniBrowser/qt/BrowserView.cpp:
     18        * MiniBrowser/qt/BrowserView.h:
     19        * MiniBrowser/qt/BrowserWindow.cpp:
     20        (BrowserWindow::BrowserWindow):
     21
    1222011-10-26  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    223
  • trunk/Tools/MiniBrowser/qt/BrowserView.cpp

    r96345 r98447  
    8686}
    8787
    88 QAction* BrowserView::navigationAction(QtWebKit::NavigationAction which) const
    89 {
    90     if (desktopWebView())
    91         return desktopWebView()->navigationController()->navigationAction(which);
    92     if (touchWebView())
    93         return touchWebView()->page()->navigationController()->navigationAction(which);
    94     Q_ASSERT(false);
    95     return 0;
    96 }
  • trunk/Tools/MiniBrowser/qt/BrowserView.h

    r96345 r98447  
    3232#include <QAction>
    3333#include <QtDeclarative/qsgcanvas.h>
    34 #include <qwebkittypes.h>
    3534
    3635class QDesktopWebView;
     
    4847    QSGItem* view() const;
    4948
    50     QAction* navigationAction(QtWebKit::NavigationAction which) const;
    51 
    5249    QTouchWebView* touchWebView() const;
    5350    QDesktopWebView* desktopWebView() const;
  • trunk/Tools/MiniBrowser/qt/BrowserWindow.cpp

    r96345 r98447  
    144144    connect(m_addressBar, SIGNAL(returnPressed()), SLOT(changeLocation()));
    145145
    146     QToolBar* bar = addToolBar("Navigation");
    147     bar->addAction(m_browser->navigationAction(QtWebKit::Back));
    148     bar->addAction(m_browser->navigationAction(QtWebKit::Forward));
    149     bar->addAction(m_browser->navigationAction(QtWebKit::Reload));
    150     bar->addAction(m_browser->navigationAction(QtWebKit::Stop));
    151     bar->addWidget(m_addressBar);
    152 
    153146    QShortcut* selectAddressBar = new QShortcut(Qt::CTRL | Qt::Key_L, this);
    154147    connect(selectAddressBar, SIGNAL(activated()), this, SLOT(openLocation()));
Note: See TracChangeset for help on using the changeset viewer.