void PageViewportControllerClientQt::setContentsScale(float localScale, bool treatAsInitialValue) { if (treatAsInitialValue) { clearRelativeZoomState(); setContentRectVisiblePositionAtScale(QPointF(), localScale); } else scaleContent(localScale); }
void PageViewportControllerClientQt::setContentRectVisiblePositionAtScale(const QPointF& location, qreal itemScale) { ASSERT(itemScale >= 0); scaleContent(itemScale); // To animate the position together with the scale we multiply the position with the current scale // and add it to the page position (displacement on the flickable contentItem because of additional items). QPointF newPosition(m_pageItem->position() + location * itemScale); m_viewportItem->setContentPos(newPosition); }
void PageViewportControllerClientQt::pinchGestureRequestUpdate(const QPointF& pinchCenterInViewportCoordinates, qreal totalScaleFactor) { ASSERT(m_controller->hasSuspendedContent()); if (!m_controller->allowsUserScaling()) return; // Changes of the center position should move the page even if the zoom factor does not change. const qreal pinchScale = m_pinchStartScale * totalScaleFactor; // Allow zooming out beyond mimimum scale on pages that do not explicitly disallow it. const qreal targetScale = m_controller->outerBoundedViewportScale(pinchScale); scaleContent(targetScale, m_viewportItem->mapToWebContent(pinchCenterInViewportCoordinates)); const QPointF positionDiff = pinchCenterInViewportCoordinates - m_lastPinchCenterInViewportCoordinates; m_lastPinchCenterInViewportCoordinates = pinchCenterInViewportCoordinates; m_viewportItem->setContentPos(m_viewportItem->contentPos() - positionDiff); }
void QtViewportHandler::pinchGestureRequestUpdate(const QPointF& pinchCenterInViewportCoordinates, qreal totalScaleFactor) { ASSERT(m_suspendCount); if (!m_allowsUserScaling) return; // Changes of the center position should move the page even if the zoom factor // does not change. const qreal cssScale = cssScaleFromItem(m_pinchStartScale * totalScaleFactor); // Allow zooming out beyond mimimum scale on pages that do not explicitly disallow it. const qreal targetCSSScale = outerBoundedCSSScale(cssScale); scaleContent(m_viewportItem->mapToWebContent(pinchCenterInViewportCoordinates), targetCSSScale); const QPointF positionDiff = pinchCenterInViewportCoordinates - m_lastPinchCenterInViewportCoordinates; m_lastPinchCenterInViewportCoordinates = pinchCenterInViewportCoordinates; m_viewportItem->setContentPos(m_viewportItem->contentPos() - positionDiff); }
void PageViewportControllerClientQt::setPageScaleFactor(float localScale) { scaleContent(localScale); }
void PageViewportControllerClientQt::setContentsScale(float localScale) { scaleContent(localScale); }