Changeset 99568 in webkit


Ignore:
Timestamp:
Nov 8, 2011, 7:34:07 AM (14 years ago)
Author:
kenneth@webkit.org
Message:

Clean up QtViewportInteractionEngine

Reviewed by Simon Hausmann.

  • UIProcess/qt/QtViewportInteractionEngine.cpp:

(WebKit::QtViewportInteractionEngine::QtViewportInteractionEngine):
(WebKit::QtViewportInteractionEngine::setItemRectVisible):

Rename the method to make it more obvious what it does. Avoid implicit
conversion to/from QVariant.

(WebKit::QtViewportInteractionEngine::pagePositionRequest):
(WebKit::QtViewportInteractionEngine::ensureContentWithinViewportBoundary):
(WebKit::QtViewportInteractionEngine::itemSizeChanged):

Only call this method on item size changes, and not for every interaction
with the viewport item. Before this change it was even being called during
animations.

  • UIProcess/qt/QtViewportInteractionEngine.h:

(WebKit::QtViewportInteractionEngine::scaleAnimationValueChanged):

Rename to make it clean that this is called from the animator.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r99551 r99568  
     12011-11-08  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        Clean up QtViewportInteractionEngine
     4
     5        Reviewed by Simon Hausmann.
     6
     7        * UIProcess/qt/QtViewportInteractionEngine.cpp:
     8        (WebKit::QtViewportInteractionEngine::QtViewportInteractionEngine):
     9        (WebKit::QtViewportInteractionEngine::setItemRectVisible):
     10
     11            Rename the method to make it more obvious what it does. Avoid implicit
     12            conversion to/from QVariant.
     13
     14        (WebKit::QtViewportInteractionEngine::pagePositionRequest):
     15        (WebKit::QtViewportInteractionEngine::ensureContentWithinViewportBoundary):
     16        (WebKit::QtViewportInteractionEngine::itemSizeChanged):
     17
     18            Only call this method on item size changes, and not for every interaction
     19            with the viewport item. Before this change it was even being called during
     20            animations.
     21
     22        * UIProcess/qt/QtViewportInteractionEngine.h:
     23        (WebKit::QtViewportInteractionEngine::scaleAnimationValueChanged):
     24
     25            Rename to make it clean that this is called from the animator.
     26
    1272011-11-08  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    228
  • trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp

    r99551 r99568  
    101101{
    102102    reset();
    103     connect(m_content, SIGNAL(xChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
    104     connect(m_content, SIGNAL(yChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
    105     connect(m_content, SIGNAL(widthChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
    106     connect(m_content, SIGNAL(heightChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
    107     connect(m_content, SIGNAL(scaleChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
    108     connect(m_scaleAnimation, SIGNAL(valueChanged(QVariant)), SLOT(updateVisibleRect(QVariant)), Qt::DirectConnection);
    109     connect(m_scaleAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))
    110             , SLOT(scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), Qt::DirectConnection);
     103
     104    connect(m_content, SIGNAL(widthChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
     105    connect(m_content, SIGNAL(heightChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
     106
     107    connect(m_scaleAnimation, SIGNAL(valueChanged(QVariant)),
     108            SLOT(scaleAnimationValueChanged(QVariant)), Qt::DirectConnection);
     109    connect(m_scaleAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)),
     110            SLOT(scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), Qt::DirectConnection);
    111111}
    112112
     
    131131}
    132132
    133 void QtViewportInteractionEngine::updateVisibleRect(QVariant rect)
    134 {
    135     ViewportUpdateGuard guard(this);
    136 
    137     QRectF visibleRect = rect.toRectF();
    138     qreal itemScale = m_viewport->width() / visibleRect.width();
     133void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect)
     134{
     135    ViewportUpdateGuard guard(this);
     136
     137    qreal itemScale = m_viewport->width() / itemRect.width();
    139138
    140139    m_content->setScale(itemScale);
     
    142141    // We need to animate the content but the position represents the viewport hence we need to invert the position here.
    143142    // To animate the position together with the scale we multiply the position with the current scale;
    144     m_content->setPos(-visibleRect.topLeft() * itemScale);
     143    m_content->setPos(- itemRect.topLeft() * itemScale);
    145144}
    146145
     
    215214    QRectF endVisibleContentRect(endPosition / endItemScale, m_viewport->boundingRect().size() / endItemScale);
    216215
    217     updateVisibleRect(endVisibleContentRect);
     216    setItemRectVisible(endVisibleContentRect);
    218217}
    219218
     
    263262        m_scaleAnimation->start();
    264263    } else
    265         updateVisibleRect(endVisibleContentRect);
     264        setItemRectVisible(endVisibleContentRect);
    266265}
    267266
     
    412411}
    413412
    414 void QtViewportInteractionEngine::contentViewportChanged()
    415 {
     413void QtViewportInteractionEngine::itemSizeChanged()
     414{
     415    // FIXME: This needs to be done smarter. What happens if it resizes when we were interacting?
    416416    if (m_pendingUpdates)
    417417        return;
  • trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h

    r99425 r99568  
    2727#include "qwebkitglobal.h"
    2828#include <QtCore/QObject>
     29#include <QtCore/QRectF>
    2930#include <QtCore/QVariant>
    3031#include <QtCore/QVariantAnimation>
     
    6667    void reset();
    6768    void setConstraints(const Constraints&);
     69    void setItemRectVisible(const QRectF&);
    6870
    6971    void pagePositionRequest(const QPoint& pos);
     
    9294private Q_SLOTS:
    9395    // Respond to changes of content that are not driven by us, like the page resizing itself.
    94     void contentViewportChanged();
    95     void updateVisibleRect(QVariant visibleRectVariant);
     96    void itemSizeChanged();
     97
    9698    void scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State);
     99    void scaleAnimationValueChanged(QVariant value) { setItemRectVisible(value.toRectF()); }
    97100
    98101private:
Note: See TracChangeset for help on using the changeset viewer.