bool QtViewportInteractionEngine::ensureContentWithinViewportBoundary(bool immediate) { ASSERT(m_suspendCount); if (scrollAnimationActive() || scaleAnimationActive()) return false; qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(currentCSSScale())); const QRectF viewportRect = m_viewport->boundingRect(); QPointF viewportHotspot = viewportRect.center(); QPointF endPosition = m_viewport->mapToWebContent(viewportHotspot) * endItemScale - viewportHotspot; QRectF endPosRange = computePosRangeForItemAtScale(endItemScale); endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight()); QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale); if (immediate) { setItemRectVisible(endVisibleContentRect); return true; } return !animateItemRectVisible(endVisibleContentRect); }
QRectF QtViewportHandler::nearestValidBounds() const { qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(currentCSSScale())); const QRectF viewportRect = m_viewportItem->boundingRect(); QPointF viewportHotspot = viewportRect.center(); QPointF endPosition = m_viewportItem->mapToWebContent(viewportHotspot) * endItemScale - viewportHotspot; QRectF endPosRange = computePosRangeForPageItemAtScale(endItemScale); endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight()); QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale); return endVisibleContentRect; }