Changeset 99568 in webkit
- Timestamp:
- Nov 8, 2011, 7:34:07 AM (14 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r99551 r99568 1 2011-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 1 27 2011-11-08 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 28 -
trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
r99551 r99568 101 101 { 102 102 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); 111 111 } 112 112 … … 131 131 } 132 132 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(); 133 void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect) 134 { 135 ViewportUpdateGuard guard(this); 136 137 qreal itemScale = m_viewport->width() / itemRect.width(); 139 138 140 139 m_content->setScale(itemScale); … … 142 141 // We need to animate the content but the position represents the viewport hence we need to invert the position here. 143 142 // 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); 145 144 } 146 145 … … 215 214 QRectF endVisibleContentRect(endPosition / endItemScale, m_viewport->boundingRect().size() / endItemScale); 216 215 217 updateVisibleRect(endVisibleContentRect);216 setItemRectVisible(endVisibleContentRect); 218 217 } 219 218 … … 263 262 m_scaleAnimation->start(); 264 263 } else 265 updateVisibleRect(endVisibleContentRect);264 setItemRectVisible(endVisibleContentRect); 266 265 } 267 266 … … 412 411 } 413 412 414 void QtViewportInteractionEngine::contentViewportChanged() 415 { 413 void QtViewportInteractionEngine::itemSizeChanged() 414 { 415 // FIXME: This needs to be done smarter. What happens if it resizes when we were interacting? 416 416 if (m_pendingUpdates) 417 417 return; -
trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
r99425 r99568 27 27 #include "qwebkitglobal.h" 28 28 #include <QtCore/QObject> 29 #include <QtCore/QRectF> 29 30 #include <QtCore/QVariant> 30 31 #include <QtCore/QVariantAnimation> … … 66 67 void reset(); 67 68 void setConstraints(const Constraints&); 69 void setItemRectVisible(const QRectF&); 68 70 69 71 void pagePositionRequest(const QPoint& pos); … … 92 94 private Q_SLOTS: 93 95 // 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 96 98 void scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State); 99 void scaleAnimationValueChanged(QVariant value) { setItemRectVisible(value.toRectF()); } 97 100 98 101 private:
Note:
See TracChangeset
for help on using the changeset viewer.