Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (99567 => 99568)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-08 15:29:58 UTC (rev 99567)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp 2011-11-08 15:34:07 UTC (rev 99568)
@@ -100,14 +100,14 @@
, m_pinchStartScale(1.f)
{
reset();
- connect(m_content, SIGNAL(xChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
- connect(m_content, SIGNAL(yChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
- connect(m_content, SIGNAL(widthChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
- connect(m_content, SIGNAL(heightChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
- connect(m_content, SIGNAL(scaleChanged()), this, SLOT(contentViewportChanged()), Qt::DirectConnection);
- connect(m_scaleAnimation, SIGNAL(valueChanged(QVariant)), SLOT(updateVisibleRect(QVariant)), Qt::DirectConnection);
- connect(m_scaleAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))
- , SLOT(scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), Qt::DirectConnection);
+
+ connect(m_content, SIGNAL(widthChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
+ connect(m_content, SIGNAL(heightChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
+
+ connect(m_scaleAnimation, SIGNAL(valueChanged(QVariant)),
+ SLOT(scaleAnimationValueChanged(QVariant)), Qt::DirectConnection);
+ connect(m_scaleAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)),
+ SLOT(scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), Qt::DirectConnection);
}
QtViewportInteractionEngine::~QtViewportInteractionEngine()
@@ -130,18 +130,17 @@
return innerBoundedCSSScale(cssScale);
}
-void QtViewportInteractionEngine::updateVisibleRect(QVariant rect)
+void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect)
{
ViewportUpdateGuard guard(this);
- QRectF visibleRect = rect.toRectF();
- qreal itemScale = m_viewport->width() / visibleRect.width();
+ qreal itemScale = m_viewport->width() / itemRect.width();
m_content->setScale(itemScale);
// We need to animate the content but the position represents the viewport hence we need to invert the position here.
// To animate the position together with the scale we multiply the position with the current scale;
- m_content->setPos(-visibleRect.topLeft() * itemScale);
+ m_content->setPos(- itemRect.topLeft() * itemScale);
}
void QtViewportInteractionEngine::scaleAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/)
@@ -214,7 +213,7 @@
QRectF endVisibleContentRect(endPosition / endItemScale, m_viewport->boundingRect().size() / endItemScale);
- updateVisibleRect(endVisibleContentRect);
+ setItemRectVisible(endVisibleContentRect);
}
QRectF QtViewportInteractionEngine::computePosRangeForItemAtScale(qreal itemScale) const
@@ -262,7 +261,7 @@
m_scaleAnimation->setEndValue(endVisibleContentRect);
m_scaleAnimation->start();
} else
- updateVisibleRect(endVisibleContentRect);
+ setItemRectVisible(endVisibleContentRect);
}
void QtViewportInteractionEngine::reset()
@@ -411,8 +410,9 @@
ensureContentWithinViewportBoundary();
}
-void QtViewportInteractionEngine::contentViewportChanged()
+void QtViewportInteractionEngine::itemSizeChanged()
{
+ // FIXME: This needs to be done smarter. What happens if it resizes when we were interacting?
if (m_pendingUpdates)
return;
Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (99567 => 99568)
--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-08 15:29:58 UTC (rev 99567)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h 2011-11-08 15:34:07 UTC (rev 99568)
@@ -26,6 +26,7 @@
#include <QScroller>
#include "qwebkitglobal.h"
#include <QtCore/QObject>
+#include <QtCore/QRectF>
#include <QtCore/QVariant>
#include <QtCore/QVariantAnimation>
@@ -65,6 +66,7 @@
void reset();
void setConstraints(const Constraints&);
+ void setItemRectVisible(const QRectF&);
void pagePositionRequest(const QPoint& pos);
@@ -91,9 +93,10 @@
private Q_SLOTS:
// Respond to changes of content that are not driven by us, like the page resizing itself.
- void contentViewportChanged();
- void updateVisibleRect(QVariant visibleRectVariant);
+ void itemSizeChanged();
+
void scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State);
+ void scaleAnimationValueChanged(QVariant value) { setItemRectVisible(value.toRectF()); }
private:
qreal cssScaleFromItem(qreal);