Changeset 93407 in webkit


Ignore:
Timestamp:
Aug 19, 2011 7:56:24 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt][WK2] Add a basic engine to control the content of the viewport
https://bugs.webkit.org/show_bug.cgi?id=66383

Patch by Benjamin Poulain <benjamin@webkit.org> on 2011-08-19
Reviewed by Andreas Kling.

Add ViewportInteractionEngine to handle the content of the viewport. The class make
sure the QTouchWebPage stays in the viewport and in the boundaries.

  • UIProcess/API/qt/qdesktopwebview.cpp:

(QDesktopWebViewPrivate::loadDidCommit):

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

(QTouchWebPage::QTouchWebPage): Set the transform origin to the top left so
we can asume the position 0, 0 is always the top left of the page.
(QTouchWebPagePrivate::_q_commitScaleChange): Make commitScaleChange a slot
in order to completely decouple the ViewportInteractionEngine and the WebKit classes.

  • UIProcess/API/qt/qtouchwebpage.h:
  • UIProcess/API/qt/qtouchwebpage_p.h:
  • UIProcess/API/qt/qtouchwebview.cpp:

(QTouchWebViewPrivate::QTouchWebViewPrivate):
(QTouchWebViewPrivate::loadDidCommit):
(QTouchWebViewPrivate::_q_viewportRectUpdated): Make _q_viewportRectUpdated() a slot
for reducing coupling.
(QTouchWebViewPrivate::updateViewportConstraints):
(QTouchWebViewPrivate::setViewportArguments):
(QTouchWebView::geometryChanged):

  • UIProcess/API/qt/qtouchwebview.h:
  • UIProcess/API/qt/qtouchwebview_p.h:
  • UIProcess/qt/ClientImpl.cpp:

(qt_wk_didCommitLoadForFrame):

  • UIProcess/qt/QtGestureRecognizer.cpp:

(WebKit::QtGestureRecognizer::QtGestureRecognizer):

  • UIProcess/qt/QtGestureRecognizer.h: Change the gesture recognizer to talk directly

to the ViewportInteractionEngine instead of interacting through TouchViewInterface.

  • UIProcess/qt/QtPanGestureRecognizer.cpp:

(WebKit::QtPanGestureRecognizer::QtPanGestureRecognizer):
(WebKit::QtPanGestureRecognizer::recognize):

  • UIProcess/qt/QtPanGestureRecognizer.h:
  • UIProcess/qt/QtPinchGestureRecognizer.cpp:

(WebKit::QtPinchGestureRecognizer::QtPinchGestureRecognizer):
(WebKit::QtPinchGestureRecognizer::recognize):

  • UIProcess/qt/QtPinchGestureRecognizer.h:
  • UIProcess/qt/QtWebPageProxy.cpp:

(QtWebPageProxy::loadDidCommit): Add the loadCommited callback in order
to reset the viewport state when the page change.

  • UIProcess/qt/QtWebPageProxy.h:
  • UIProcess/qt/TouchViewInterface.cpp:

(WebKit::TouchViewInterface::TouchViewInterface):
(WebKit::TouchViewInterface::contentSizeChanged):
(WebKit::TouchViewInterface::loadDidCommit):

  • UIProcess/qt/TouchViewInterface.h:
  • UIProcess/qt/ViewInterface.h:
  • UIProcess/qt/ViewportInteractionEngine.cpp: Added.

(WebKit::visibleRectInContentCoordinate):
(WebKit::contentRectInViewportCoordinate):
(WebKit::ViewportUpdateGuard::ViewportUpdateGuard):
(WebKit::ViewportUpdateGuard::~ViewportUpdateGuard):
(WebKit::ViewportInteractionEngine::ViewportInteractionEngine):
(WebKit::ViewportInteractionEngine::reset):
(WebKit::ViewportInteractionEngine::setConstraints):
(WebKit::ViewportInteractionEngine::panGestureStarted):
(WebKit::ViewportInteractionEngine::panGestureRequestScroll):
(WebKit::ViewportInteractionEngine::panGestureCancelled):
(WebKit::ViewportInteractionEngine::panGestureEnded):
(WebKit::ViewportInteractionEngine::pinchGestureStarted):
(WebKit::ViewportInteractionEngine::pinchGestureRequestUpdate):
(WebKit::ViewportInteractionEngine::pinchGestureEnded):
(WebKit::ViewportInteractionEngine::contentGeometryChanged):
(WebKit::ViewportInteractionEngine::contentScaleChanged):
(WebKit::ViewportInteractionEngine::updateContentIfNeeded):
(WebKit::ViewportInteractionEngine::updateContentScaleIfNeeded):
(WebKit::ViewportInteractionEngine::updateContentPositionIfNeeded):
(WebKit::ViewportInteractionEngine::animateContentPositionToBoundaries):
(WebKit::ViewportInteractionEngine::animateContentScaleToBoundaries):
(WebKit::ViewportInteractionEngine::scaleContent):

  • UIProcess/qt/ViewportInteractionEngine.h: Added.

(WebKit::ViewportInteractionEngine::Constraints::Constraints):
(WebKit::operator==):

  • UIProcess/qt/qtouchwebpageproxy.cpp:

(QTouchWebPageProxy::QTouchWebPageProxy):

  • UIProcess/qt/qtouchwebpageproxy.h:
  • WebKit2.pro:
Location:
trunk/Source/WebKit2
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r93402 r93407  
     12011-08-19  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [Qt][WK2] Add a basic engine to control the content of the viewport
     4        https://bugs.webkit.org/show_bug.cgi?id=66383
     5
     6        Reviewed by Andreas Kling.
     7
     8        Add ViewportInteractionEngine to handle the content of the viewport. The class make
     9        sure the QTouchWebPage stays in the viewport and in the boundaries.
     10
     11        * UIProcess/API/qt/qdesktopwebview.cpp:
     12        (QDesktopWebViewPrivate::loadDidCommit):
     13        * UIProcess/API/qt/qdesktopwebview_p.h:
     14        * UIProcess/API/qt/qtouchwebpage.cpp:
     15        (QTouchWebPage::QTouchWebPage): Set the transform origin to the top left so
     16        we can asume the position 0, 0 is always the top left of the page.
     17        (QTouchWebPagePrivate::_q_commitScaleChange): Make commitScaleChange a slot
     18        in order to completely decouple the ViewportInteractionEngine and the WebKit classes.
     19        * UIProcess/API/qt/qtouchwebpage.h:
     20        * UIProcess/API/qt/qtouchwebpage_p.h:
     21        * UIProcess/API/qt/qtouchwebview.cpp:
     22        (QTouchWebViewPrivate::QTouchWebViewPrivate):
     23        (QTouchWebViewPrivate::loadDidCommit):
     24        (QTouchWebViewPrivate::_q_viewportRectUpdated): Make _q_viewportRectUpdated() a slot
     25        for reducing coupling.
     26        (QTouchWebViewPrivate::updateViewportConstraints):
     27        (QTouchWebViewPrivate::setViewportArguments):
     28        (QTouchWebView::geometryChanged):
     29        * UIProcess/API/qt/qtouchwebview.h:
     30        * UIProcess/API/qt/qtouchwebview_p.h:
     31        * UIProcess/qt/ClientImpl.cpp:
     32        (qt_wk_didCommitLoadForFrame):
     33        * UIProcess/qt/QtGestureRecognizer.cpp:
     34        (WebKit::QtGestureRecognizer::QtGestureRecognizer):
     35        * UIProcess/qt/QtGestureRecognizer.h: Change the gesture recognizer to talk directly
     36        to the ViewportInteractionEngine instead of interacting through TouchViewInterface.
     37        * UIProcess/qt/QtPanGestureRecognizer.cpp:
     38        (WebKit::QtPanGestureRecognizer::QtPanGestureRecognizer):
     39        (WebKit::QtPanGestureRecognizer::recognize):
     40        * UIProcess/qt/QtPanGestureRecognizer.h:
     41        * UIProcess/qt/QtPinchGestureRecognizer.cpp:
     42        (WebKit::QtPinchGestureRecognizer::QtPinchGestureRecognizer):
     43        (WebKit::QtPinchGestureRecognizer::recognize):
     44        * UIProcess/qt/QtPinchGestureRecognizer.h:
     45        * UIProcess/qt/QtWebPageProxy.cpp:
     46        (QtWebPageProxy::loadDidCommit): Add the loadCommited callback in order
     47        to reset the viewport state when the page change.
     48        * UIProcess/qt/QtWebPageProxy.h:
     49        * UIProcess/qt/TouchViewInterface.cpp:
     50        (WebKit::TouchViewInterface::TouchViewInterface):
     51        (WebKit::TouchViewInterface::contentSizeChanged):
     52        (WebKit::TouchViewInterface::loadDidCommit):
     53        * UIProcess/qt/TouchViewInterface.h:
     54        * UIProcess/qt/ViewInterface.h:
     55        * UIProcess/qt/ViewportInteractionEngine.cpp: Added.
     56        (WebKit::visibleRectInContentCoordinate):
     57        (WebKit::contentRectInViewportCoordinate):
     58        (WebKit::ViewportUpdateGuard::ViewportUpdateGuard):
     59        (WebKit::ViewportUpdateGuard::~ViewportUpdateGuard):
     60        (WebKit::ViewportInteractionEngine::ViewportInteractionEngine):
     61        (WebKit::ViewportInteractionEngine::reset):
     62        (WebKit::ViewportInteractionEngine::setConstraints):
     63        (WebKit::ViewportInteractionEngine::panGestureStarted):
     64        (WebKit::ViewportInteractionEngine::panGestureRequestScroll):
     65        (WebKit::ViewportInteractionEngine::panGestureCancelled):
     66        (WebKit::ViewportInteractionEngine::panGestureEnded):
     67        (WebKit::ViewportInteractionEngine::pinchGestureStarted):
     68        (WebKit::ViewportInteractionEngine::pinchGestureRequestUpdate):
     69        (WebKit::ViewportInteractionEngine::pinchGestureEnded):
     70        (WebKit::ViewportInteractionEngine::contentGeometryChanged):
     71        (WebKit::ViewportInteractionEngine::contentScaleChanged):
     72        (WebKit::ViewportInteractionEngine::updateContentIfNeeded):
     73        (WebKit::ViewportInteractionEngine::updateContentScaleIfNeeded):
     74        (WebKit::ViewportInteractionEngine::updateContentPositionIfNeeded):
     75        (WebKit::ViewportInteractionEngine::animateContentPositionToBoundaries):
     76        (WebKit::ViewportInteractionEngine::animateContentScaleToBoundaries):
     77        (WebKit::ViewportInteractionEngine::scaleContent):
     78        * UIProcess/qt/ViewportInteractionEngine.h: Added.
     79        (WebKit::ViewportInteractionEngine::Constraints::Constraints):
     80        (WebKit::operator==):
     81        * UIProcess/qt/qtouchwebpageproxy.cpp:
     82        (QTouchWebPageProxy::QTouchWebPageProxy):
     83        * UIProcess/qt/qtouchwebpageproxy.h:
     84        * WebKit2.pro:
     85
    1862011-08-19  Lars Knudsen  <lars.knudsen@nokia.com>
    287
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp

    r92851 r93407  
    132132}
    133133
     134void QDesktopWebViewPrivate::loadDidCommit()
     135{
     136    // Not used for QDesktopWebView.
     137}
     138
    134139void QDesktopWebViewPrivate::loadDidSucceed()
    135140{
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h

    r92851 r93407  
    6262    virtual void didChangeCursor(const QCursor&);
    6363    virtual void loadDidBegin();
     64    virtual void loadDidCommit();
    6465    virtual void loadDidSucceed();
    6566    virtual void loadDidFail(const QWebError&);
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp

    r92376 r93407  
    3535{
    3636    setFlag(ItemHasContents);
     37
     38    // We do the transform from the top left so the viewport can assume the position 0, 0
     39    // is always where rendering starts.
     40    setTransformOrigin(TopLeft);
    3741}
    3842
     
    146150}
    147151
     152void QTouchWebPagePrivate::_q_commitScaleChange()
     153{
     154    commitScaleChange();
     155}
     156
    148157void QTouchWebPagePrivate::commitScaleChange()
    149158{
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h

    r93049 r93407  
    7979
    8080private:
     81    Q_PRIVATE_SLOT(d, void _q_commitScaleChange());
     82
    8183    QTouchWebPagePrivate* d;
    8284    friend class QTouchWebViewPrivate;
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h

    r93049 r93407  
    4040
    4141    void setViewportRect(const QRectF&);
     42    void _q_commitScaleChange();
    4243    void commitScaleChange();
    4344
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp

    r93049 r93407  
    3434    , pageView(new QTouchWebPage(q))
    3535    , viewInterface(q, pageView.data())
    36     , page(&viewInterface, defaultWKContext())
     36    , interactionEngine(q, pageView.data())
     37    , page(&viewInterface, &interactionEngine, defaultWKContext())
    3738{
    3839    QTouchWebPagePrivate* const pageViewPrivate = pageView.data()->d;
    3940    pageViewPrivate->setPage(&page);
     41
     42    QObject::connect(&interactionEngine, SIGNAL(viewportUpdateRequested()), q, SLOT(_q_viewportRectUpdated()));
     43    QObject::connect(&interactionEngine, SIGNAL(commitScaleChange()), pageView.data(), SLOT(_q_commitScaleChange()));
    4044}
    4145
    42 void QTouchWebViewPrivate::scroll(qreal deltaX, qreal deltaY)
     46void QTouchWebViewPrivate::loadDidCommit()
    4347{
    44     pageView->setX(pageView->x() + deltaX);
    45     pageView->setY(pageView->y() + deltaY);
    46     viewportRectUpdated();
     48    interactionEngine.reset();
    4749}
    4850
    49 void QTouchWebViewPrivate::viewportRectUpdated()
     51void QTouchWebViewPrivate::_q_viewportRectUpdated()
    5052{
    5153    QTouchWebPagePrivate* const pageViewPrivate = pageView.data()->d;
     
    5456}
    5557
    56 void QTouchWebViewPrivate::updateViewportState()
     58void QTouchWebViewPrivate::updateViewportConstraints()
    5759{
    5860    QSize availableSize = q->boundingRect().size().toSize();
     
    6365    WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, wkPrefs->layoutFallbackWidth(), wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
    6466
    65     viewport.initialScale = attr.initialScale;
    66     viewport.minimumScale = attr.minimumScale;
    67     viewport.maximumScale = attr.maximumScale;
    68     viewport.pixelRatio = attr.devicePixelRatio;
    69     viewport.isUserScalable = !!attr.userScalable;
     67    ViewportInteractionEngine::Constraints newConstraints;
     68    newConstraints.initialScale = attr.initialScale;
     69    newConstraints.minimumScale = attr.minimumScale;
     70    newConstraints.maximumScale = attr.maximumScale;
     71    newConstraints.isUserScalable = !!attr.userScalable;
     72    interactionEngine.setConstraints(newConstraints);
    7073
    7174    // Overwrite minimum scale value with fit-to-view value, unless the the content author
     
    8083{
    8184    viewportArguments = args;
    82     updateViewportState();
     85    updateViewportConstraints();
    8386}
    8487
     
    104107    QSGItem::geometryChanged(newGeometry, oldGeometry);
    105108    if (newGeometry.size() != oldGeometry.size()) {
    106         d->updateViewportState();
    107         d->viewportRectUpdated();
     109        d->updateViewportConstraints();
     110        d->_q_viewportRectUpdated();
    108111    }
    109112}
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview.h

    r92277 r93407  
    4848
    4949private:
     50    Q_PRIVATE_SLOT(d, void _q_viewportRectUpdated());
     51
    5052    friend class WebKit::TouchViewInterface;
    5153    QTouchWebViewPrivate *d;
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h

    r92851 r93407  
    2525#include "qtouchwebpageproxy.h"
    2626#include "TouchViewInterface.h"
     27#include "ViewportInteractionEngine.h"
    2728
    2829class QTouchWebPage;
     
    3435    QTouchWebViewPrivate(QTouchWebView* q);
    3536
    36     void scroll(qreal deltaX, qreal deltaY);
    37     void viewportRectUpdated();
    38     void updateViewportState();
     37    void loadDidCommit();
     38    void _q_viewportRectUpdated();
     39    void updateViewportConstraints();
    3940
    4041    void setViewportArguments(const WebCore::ViewportArguments& args);
    41 
    42     struct ViewportState {
    43         ViewportState()
    44             : initialScale(1.0)
    45             , minimumScale(0.25)
    46             , maximumScale(1.8)
    47             , pixelRatio(1.0)
    48             , isUserScalable(true)
    49         { }
    50 
    51         qreal initialScale;
    52         qreal minimumScale;
    53         qreal maximumScale;
    54         qreal pixelRatio;
    55         bool isUserScalable;
    56     } viewport;
    5742
    5843    QTouchWebView* const q;
    5944    QScopedPointer<QTouchWebPage> pageView;
    6045    WebKit::TouchViewInterface viewInterface;
     46    ViewportInteractionEngine interactionEngine;
    6147    QTouchWebPageProxy page;
    6248
  • trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp

    r91840 r93407  
    9696    toQtWebPageProxy(clientInfo)->updateNavigationActions();
    9797    toQtWebPageProxy(clientInfo)->didChangeUrl(qUrl);
     98    toQtWebPageProxy(clientInfo)->loadDidCommit();
    9899}
    99100
  • trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp

    r90838 r93407  
    2929namespace WebKit {
    3030
    31 QtGestureRecognizer::QtGestureRecognizer(TouchViewInterface* touchViewInterface)
    32     : m_touchViewInterface(touchViewInterface)
     31QtGestureRecognizer::QtGestureRecognizer(ViewportInteractionEngine* viewportInteractionEngine)
     32    : m_viewportInteractionEngine(viewportInteractionEngine)
    3333    , m_state(NoGesture)
    3434{
    35     ASSERT(touchViewInterface);
     35    ASSERT(viewportInteractionEngine);
    3636}
    3737
  • trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h

    r90838 r93407  
    2929namespace WebKit {
    3030
    31 class TouchViewInterface;
     31class ViewportInteractionEngine;
    3232
    3333class QtGestureRecognizer {
    3434protected:
    35     QtGestureRecognizer(TouchViewInterface*);
     35    QtGestureRecognizer(ViewportInteractionEngine*);
    3636    void reset();
    3737
    38     TouchViewInterface* const m_touchViewInterface;
     38    ViewportInteractionEngine* const m_viewportInteractionEngine;
    3939    enum State {
    4040        NoGesture,
  • trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp

    r90838 r93407  
    2424 */
    2525#include "config.h"
     26
    2627#include "QtPanGestureRecognizer.h"
    2728
    28 #include "TouchViewInterface.h"
     29#include "ViewportInteractionEngine.h"
    2930#include <QTouchEvent>
    3031
    3132namespace WebKit {
    3233
    33 QtPanGestureRecognizer::QtPanGestureRecognizer(TouchViewInterface* touchViewInterface)
    34     : QtGestureRecognizer(touchViewInterface)
     34QtPanGestureRecognizer::QtPanGestureRecognizer(ViewportInteractionEngine* interactionEngine)
     35    : QtGestureRecognizer(interactionEngine)
    3536{
    3637    reset();
     
    4647    if (event->touchPoints().size() > 1) {
    4748        if (m_state == GestureRecognized)
    48             m_touchViewInterface->panGestureCancelled();
     49            m_viewportInteractionEngine->panGestureCancelled();
    4950        reset();
    5051        return false;
     
    6970
    7071            m_state = GestureRecognized;
    71             m_touchViewInterface->panGestureStarted();
     72            m_viewportInteractionEngine->panGestureStarted();
    7273        }
    7374
     
    7576        // Offset sent to the views must be in page view coordinate space.
    7677        QPointF offsetSinceLastEvent(touchPoint.pos() - touchPoint.lastPos());
    77         m_touchViewInterface->panGestureRequestScroll(offsetSinceLastEvent.x(), offsetSinceLastEvent.y());
     78        m_viewportInteractionEngine->panGestureRequestUpdate(offsetSinceLastEvent.x(), offsetSinceLastEvent.y());
    7879        return true;
    7980    }
    8081    case QEvent::TouchEnd:
    8182        if (m_state == GestureRecognized) {
    82             m_touchViewInterface->panGestureEnded();
     83            m_viewportInteractionEngine->panGestureEnded();
    8384            reset();
    8485            return true;
  • trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h

    r90838 r93407  
    4242class QtPanGestureRecognizer : private QtGestureRecognizer {
    4343public:
    44     QtPanGestureRecognizer(TouchViewInterface*);
     44    QtPanGestureRecognizer(ViewportInteractionEngine*);
    4545    bool recognize(const QTouchEvent*);
    4646    void reset();
  • trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp

    r90838 r93407  
    2727#include "QtPinchGestureRecognizer.h"
    2828
    29 #include "TouchViewInterface.h"
     29#include "ViewportInteractionEngine.h"
    3030#include <QtCore/QLineF>
    3131
     
    5050}
    5151
    52 QtPinchGestureRecognizer::QtPinchGestureRecognizer(TouchViewInterface* touchViewInterface)
    53     : QtGestureRecognizer(touchViewInterface)
     52QtPinchGestureRecognizer::QtPinchGestureRecognizer(ViewportInteractionEngine* interactionEngine)
     53    : QtGestureRecognizer(interactionEngine)
    5454{
    5555    reset();
     
    6161    if (touchPoints.size() < 2) {
    6262        if (m_state == GestureRecognized)
    63             m_touchViewInterface->pinchGestureEnded();
     63            m_viewportInteractionEngine->pinchGestureEnded();
    6464        reset();
    6565        return false;
     
    9797                    return false;
    9898                m_state = GestureRecognized;
    99                 m_touchViewInterface->pinchGestureStarted();
     99                m_viewportInteractionEngine->pinchGestureStarted();
    100100
    101101                // We reset the initial position to the previous position in order to avoid the jump caused
     
    111111            const qreal totalScaleFactor = currentSpanDistance / initialSpanDistance;
    112112            const QPointF touchCenterInPageViewCoordinate = computeTouchCenter(point1, point2);
    113             m_touchViewInterface->pinchGestureRequestUpdate(touchCenterInPageViewCoordinate, totalScaleFactor);
     113            m_viewportInteractionEngine->pinchGestureRequestUpdate(touchCenterInPageViewCoordinate, totalScaleFactor);
    114114            return true;
    115115            break;
     
    118118    case QEvent::TouchEnd:
    119119        if (m_state == GestureRecognized) {
    120             m_touchViewInterface->pinchGestureEnded();
     120            m_viewportInteractionEngine->pinchGestureEnded();
    121121            reset();
    122122            return true;
  • trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h

    r90838 r93407  
    3939namespace WebKit {
    4040
    41 class TouchViewInterface;
    42 
    4341class QtPinchGestureRecognizer : private QtGestureRecognizer {
    4442public:
     
    5351    };
    5452
    55     QtPinchGestureRecognizer(TouchViewInterface*);
     53    QtPinchGestureRecognizer(ViewportInteractionEngine*);
    5654    bool recognize(const QTouchEvent*);
    5755    void reset();
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r93402 r93407  
    421421}
    422422
     423void QtWebPageProxy::loadDidCommit()
     424{
     425    m_viewInterface->loadDidCommit();
     426}
     427
    423428void QtWebPageProxy::loadDidSucceed()
    424429{
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r93402 r93407  
    134134
    135135    void loadDidBegin();
     136    void loadDidCommit();
    136137    void loadDidSucceed();
    137138    void loadDidFail(const QWebError&);
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp

    r92851 r93407  
    3232    : m_viewportView(viewportView)
    3333    , m_pageView(pageView)
    34     , m_pinchStartScale(1.f)
    3534{
    3635    Q_ASSERT(m_viewportView);
    3736    Q_ASSERT(m_pageView);
    38 }
    39 
    40 void TouchViewInterface::panGestureStarted()
    41 {
    42     // FIXME: suspend the Web engine (stop animated GIF, etc).
    43     // FIXME: initialize physics for panning (stop animation, etc).
    44 }
    45 
    46 void TouchViewInterface::panGestureRequestScroll(qreal deltaX, qreal deltaY)
    47 {
    48     // Translate the delta from page to viewport coordinates.
    49     QPointF itemPositionInItemCoords = m_pageView->mapFromItem(m_pageView->parentItem(), m_pageView->pos());
    50     QPointF destInViewportCoords = m_viewportView->mapFromItem(m_pageView, itemPositionInItemCoords + QPointF(deltaX, deltaY));
    51     QPointF offsetInViewportCoords = destInViewportCoords - m_viewportView->mapFromItem(m_pageView->parentItem(), m_pageView->pos());
    52     m_viewportView->d->scroll(offsetInViewportCoords.x(), offsetInViewportCoords.y());
    53 }
    54 
    55 void TouchViewInterface::panGestureEnded()
    56 {
    57     // FIXME: trigger physics engine for animation (the Web engine should be resumed after the animation.)
    58 }
    59 
    60 void TouchViewInterface::panGestureCancelled()
    61 {
    62     // FIXME: reset physics.
    63     // FIXME: resume the Web engine.
    64 }
    65 
    66 void TouchViewInterface::pinchGestureStarted()
    67 {
    68     // FIXME: suspend the engine.
    69     m_pinchStartScale = m_pageView->scale();
    70 }
    71 
    72 void TouchViewInterface::pinchGestureRequestUpdate(const QPointF& pinchCenterInPageViewCoordinate, qreal totalScaleFactor)
    73 {
    74     // FIXME: it is a more complicated than that:
    75     // -the scale should be done centered on the pinch center.
    76     // -changes of the center position should move the page even if the zoom factor
    77     //  does not change. Both the zoom and the panning should be handled through the physics engine.
    78     const qreal scale = m_pinchStartScale * totalScaleFactor;
    79     QPointF oldPinchCenterOnParent = m_pageView->mapToItem(m_pageView->parentItem(), pinchCenterInPageViewCoordinate);
    80     m_pageView->setScale(scale);
    81     QPointF newPinchCenterOnParent = m_pageView->mapToItem(m_pageView->parentItem(), pinchCenterInPageViewCoordinate);
    82     m_pageView->setPos(m_pageView->pos() - (newPinchCenterOnParent - oldPinchCenterOnParent));
    83 }
    84 
    85 void TouchViewInterface::pinchGestureEnded()
    86 {
    87     // FIXME: commit scale with the scale value in the valid range in order to get new tiles.
    88     // FIXME: animate the back zoom in the valid range.
    89     // FIXME: resume the engine after the animation.
    90     m_pageView->d->commitScaleChange();
    91     m_viewportView->d->viewportRectUpdated();
    9237}
    9338
     
    11257void TouchViewInterface::contentSizeChanged(const QSize& newSize)
    11358{
    114     // FIXME: the viewport should take care of:
    115     // -resize the page
    116     // -change the zoom level if needed
    117     // -move the page back in viewport boundaries if needed
    118     // -update the viewport rect
    11959    m_pageView->setWidth(newSize.width());
    12060    m_pageView->setHeight(newSize.height());
    121     m_viewportView->d->viewportRectUpdated();
     61    m_viewportView->d->updateViewportConstraints();
    12262}
    12363
     
    179119}
    180120
     121void TouchViewInterface::loadDidCommit()
     122{
     123    m_viewportView->d->loadDidCommit();
     124}
     125
    181126void TouchViewInterface::loadDidSucceed()
    182127{
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h

    r92851 r93407  
    4141    TouchViewInterface(QTouchWebView* viewportView, QTouchWebPage* pageView);
    4242
    43     void panGestureStarted();
    44     void panGestureRequestScroll(qreal deltaX, qreal deltaY);
    45     void panGestureEnded();
    46     void panGestureCancelled();
    47 
    48     void pinchGestureStarted();
    49     void pinchGestureRequestUpdate(const QPointF&, qreal);
    50     void pinchGestureEnded();
    51 
    5243    SGAgent* sceneGraphAgent() const;
    5344
     
    7465    virtual void didChangeCursor(const QCursor&);
    7566    virtual void loadDidBegin();
     67    virtual void loadDidCommit();
    7668    virtual void loadDidSucceed();
    7769    virtual void loadDidFail(const QWebError&);
     
    8779    QTouchWebView* const m_viewportView;
    8880    QTouchWebPage* const m_pageView;
    89 
    90     qreal m_pinchStartScale;
    9181};
    9282
  • trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h

    r92851 r93407  
    6868    virtual void didChangeCursor(const QCursor&) = 0;
    6969    virtual void loadDidBegin() = 0;
     70    virtual void loadDidCommit() = 0;
    7071    virtual void loadDidSucceed() = 0;
    7172    virtual void loadDidFail(const QWebError&) = 0;
  • trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp

    r92851 r93407  
    2828using namespace WebCore;
    2929
    30 QTouchWebPageProxy::QTouchWebPageProxy(TouchViewInterface* viewInterface, QWKContext* context, WKPageGroupRef pageGroupRef)
     30QTouchWebPageProxy::QTouchWebPageProxy(TouchViewInterface* viewInterface, ViewportInteractionEngine* viewportInteractionEngine, QWKContext* context, WKPageGroupRef pageGroupRef)
    3131    : QtWebPageProxy(viewInterface, context, pageGroupRef)
    32     , m_panGestureRecognizer(viewInterface)
    33     , m_pinchGestureRecognizer(viewInterface)
     32    , m_panGestureRecognizer(viewportInteractionEngine)
     33    , m_pinchGestureRecognizer(viewportInteractionEngine)
    3434{
    3535    init();
  • trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.h

    r92851 r93407  
    3131#include <wtf/PassOwnPtr.h>
    3232
     33namespace WebKit {
     34class ViewportInteractionEngine;
     35}
     36
    3337using namespace WebKit;
    3438
     
    3640{
    3741public:
    38     QTouchWebPageProxy(TouchViewInterface*, QWKContext*, WKPageGroupRef = 0);
     42    QTouchWebPageProxy(TouchViewInterface*, ViewportInteractionEngine*, QWKContext*, WKPageGroupRef = 0);
    3943
    4044    virtual bool handleEvent(QEvent*);
  • trunk/Source/WebKit2/WebKit2.pro

    r92376 r93407  
    253253    UIProcess/qt/SGTileNode.h \
    254254    UIProcess/qt/ViewInterface.h \
     255    UIProcess/qt/ViewportInteractionEngine.h \
    255256    UIProcess/qt/WebUndoCommandQt.h \
    256257    UIProcess/qt/WebContextMenuProxyQt.h \
     
    484485    UIProcess/qt/TiledDrawingAreaTileQt.cpp \
    485486    UIProcess/qt/TextCheckerQt.cpp \
     487    UIProcess/qt/ViewportInteractionEngine.cpp \
    486488    UIProcess/qt/WebContextMenuProxyQt.cpp \
    487489    UIProcess/qt/WebContextQt.cpp \
Note: See TracChangeset for help on using the changeset viewer.