void PageViewportControllerClientQt::animateContentRectVisible(const QRectF& contentRect) { ASSERT(m_scaleAnimation->state() == QAbstractAnimation::Stopped); ASSERT(!scrollAnimationActive()); if (scrollAnimationActive()) return; QRectF viewportRectInContentCoords = m_viewportItem->mapRectToWebContent(m_viewportItem->boundingRect()); if (contentRect == viewportRectInContentCoords) { m_scaleChange.end(); updateViewportController(); return; } // Inform the web process about the requested visible content rect immediately so that new tiles // are rendered at the final destination during the animation. m_controller->didChangeContentsVisibility(contentRect.topLeft(), viewportScaleForRect(contentRect)); // Since we have to animate scale and position at the same time the scale animation interpolates // from the current viewport rect in content coordinates to a visible rect of the content. m_scaleAnimation->setStartValue(viewportRectInContentCoords); m_scaleAnimation->setEndValue(contentRect); m_scaleAnimation->start(); }
void PageViewportControllerClientQt::pageItemPositionChanged() { if (m_ignoreViewportChanges) return; QPointF newPosition = m_viewportItem->contentPos(); updateViewportController(m_lastScrollPosition - newPosition); m_lastScrollPosition = newPosition; }
void PageViewportControllerClientQt::scaleAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/) { switch (newState) { case QAbstractAnimation::Running: m_scaleChange.begin(); break; case QAbstractAnimation::Stopped: m_scaleChange.end(); updateViewportController(); break; default: break; } }
void PageViewportControllerClientQt::resumeAndUpdateContent() { m_controller->resumeContent(); // Make sure that tiles all around the viewport will be requested. updateViewportController(); }
void PageViewportControllerClientQt::setContentsRectToNearestValidBounds() { float targetScale = m_controller->innerBoundedViewportScale(m_pageItem->contentsScale()); setContentRectVisiblePositionAtScale(nearestValidVisibleContentsRect().topLeft(), targetScale); updateViewportController(); }
void PageViewportControllerClientQt::didResumeContent() { // Make sure that tiles all around the viewport will be requested. updateViewportController(); }
void PageViewportControllerClientQt::setViewportPosition(const FloatPoint& contentsPoint) { QPointF newPosition((m_pageItem->position() + QPointF(contentsPoint)) * m_pageItem->contentsScale()); m_viewportItem->setContentPos(newPosition); updateViewportController(); }
void PageViewportControllerClientQt::pinchGestureCancelled() { m_pinchStartScale = -1; m_scaleChange.end(); updateViewportController(); }
void PageViewportControllerClientQt::flickMoveEnded() { // This method is called on the end of the pan or pan kinetic animation. m_scrollChange.end(); updateViewportController(); }