예제 #1
0
void WebPages::updateActivePage(WebPageEntry *webPageEntry, bool resurrect)
{
    DeclarativeWebPage * activeWebPage = 0;
    if (m_activePage && (activeWebPage = m_activePage->webPage)) {
        m_activePage->cssContentRect = new QRectF(activeWebPage->contentRect());
        activeWebPage->setVisible(false);

        // Allow subpending only current active is not creator (parent).
        if (webPageEntry->webPage->parentId() != (int)activeWebPage->uniqueID()) {
             if (activeWebPage->loading()) {
                 activeWebPage->stop();
             }
             activeWebPage->suspendView();
        }
    }

    m_activePage = webPageEntry;
    activeWebPage = m_activePage->webPage;
    if (resurrect && activeWebPage) {
        // Copy rect value
        activeWebPage->setResurrectedContentRect(*m_activePage->cssContentRect);
        delete m_activePage->cssContentRect;
        m_activePage->cssContentRect = 0;
    }

    if (activeWebPage) {
        activeWebPage->resumeView();
        activeWebPage->setVisible(true);
    }
}
예제 #2
0
void WebPageQueue::virtualizeInactive()
{
    if (!m_livePagePrepended || m_queue.isEmpty() || !m_queue.at(0)->webPage) {
        // no need to iterate through a queue of only one or zero live pages
        return;
    }

    DeclarativeWebPage* livePage = m_queue.at(0)->webPage;

    for (int i = 1; i < m_queue.count(); ++i) {
        DeclarativeWebPage* page = m_queue.at(i)->webPage;
        if (page &&
                (livePage->parentId() != (int)page->uniqueID() || (int)livePage->uniqueID() != page->parentId())) {
            release(m_queue.at(i)->tabId, true);
        }
    }

    m_livePagePrepended = false;
}
예제 #3
0
WebPageActivationData WebPages::page(int tabId, int parentId)
{
    if (!m_webPageComponent) {
        qWarning() << "TabModel not initialized!";
        return WebPageActivationData(0, false);
    }

    if (m_activePage && m_activePage->webPage && m_activePage->webPage->tabId() == tabId) {
        m_activePage->webPage->resumeView();
        m_activePage->webPage->setVisible(true);
        return WebPageActivationData(m_activePage->webPage, false);
    }

#ifdef DEBUG_LOGS
    qDebug() << "about to create a new tab or activate old:" << tabId;
#endif

    WebPageEntry *pageEntry = m_activePages.value(tabId, 0);
    bool resurrect = pageEntry && !pageEntry->webPage;
    if (!pageEntry || resurrect) {
        QQmlContext *creationContext = m_webPageComponent->creationContext();
        QQmlContext *context = new QQmlContext(creationContext ? creationContext : QQmlEngine::contextForObject(m_webContainer));
        QObject *object = m_webPageComponent->beginCreate(context);
        if (object) {
            context->setParent(object);
            object->setParent(m_webContainer);
            DeclarativeWebPage *webPage = qobject_cast<DeclarativeWebPage *>(object);
            if (webPage) {
                webPage->setParentItem(m_webContainer);
                webPage->setParentID(parentId);
                webPage->setTabId(tabId);
                webPage->setContainer(m_webContainer);
                if (!pageEntry) {
                    pageEntry = new WebPageEntry(webPage, 0);
                } else {
                    pageEntry->webPage = webPage;
                }

                m_webPageComponent->completeCreate();
#ifdef DEBUG_LOGS
                qDebug() << "New view id:" << webPage->uniqueID() << "parentId:" << webPage->parentId() << "tab id:" << webPage->tabId();
#endif
                m_activePages.insert(tabId, pageEntry);
                ++m_count;
            } else {
                qmlInfo(m_webContainer) << "webPage component must be a WebPage component";
            }
        } else {
            qmlInfo(m_webContainer) << "Creation of the web page failed. Error: " << m_webPageComponent->errorString();
            delete object;
            object = 0;
        }
    }

    updateActivePage(pageEntry, resurrect);
#ifdef DEBUG_LOGS
    dumpPages();
#endif

    return WebPageActivationData(pageEntry->webPage, true);
}