bool PageViewportController::updateMinimumScaleToFit(bool userInitiatedUpdate)
{
    if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
        return false;

    bool currentlyScaledToFit = fuzzyCompare(m_effectiveScale, toViewportScale(m_minimumScaleToFit), 0.001);

    float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize), devicePixelRatio());

    if (minimumScale <= 0)
        return false;

    if (!fuzzyCompare(minimumScale, m_minimumScaleToFit, 0.001)) {
        m_minimumScaleToFit = minimumScale;

        if (!hasSuspendedContent()) {
            if (!m_hadUserInteraction || (userInitiatedUpdate && currentlyScaledToFit))
                applyScaleAfterRenderingContents(toViewportScale(m_minimumScaleToFit));
            else {
                // Ensure the effective scale stays within bounds.
                float boundedScale = innerBoundedViewportScale(m_effectiveScale);
                if (!fuzzyCompare(boundedScale, m_effectiveScale, 0.001))
                    applyScaleAfterRenderingContents(boundedScale);
            }
        }

        return true;
    }
    return false;
}
Example #2
0
void PageViewportController::pageTransitionViewportReady()
{
    if (!m_rawAttributes.layoutSize.isEmpty()) {
        m_hadUserInteraction = false;
        ASSERT(m_rawAttributes.initialScale > 0);
        applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(m_rawAttributes.initialScale)));
    }

    // At this point we should already have received the first viewport arguments and the requested scroll
    // position for the newly loaded page and sent our reactions to the web process. It's now safe to tell
    // the web process to start rendering the new page contents and possibly re-use the current tiles.
    // This assumes that all messages have been handled in order and that nothing has been pushed back on the event loop.
    m_webPageProxy->commitPageTransitionViewport();
}
Example #3
0
bool PageViewportController::updateMinimumScaleToFit()
{
    if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
        return false;

    float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize), devicePixelRatio());

    if (minimumScale <= 0)
        return false;

    if (!fuzzyCompare(minimumScale, m_minimumScaleToFit, 0.001)) {
        m_minimumScaleToFit = minimumScale;

        if (!m_hadUserInteraction && !hasSuspendedContent())
            applyScaleAfterRenderingContents(toViewportScale(minimumScale));

        return true;
    }
    return false;
}