void CoordinatedDrawingArea::viewStateDidChange(ViewState::Flags changed, bool, const Vector<uint64_t>&)
{
    if (changed & ViewState::IsVisible) {
        if (m_webPage.isVisible())
            resumePainting();
        else
            suspendPainting();
    }
}
Example #2
0
void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)
{
    ASSERT(!m_inUpdateBackingStoreState);
    m_inUpdateBackingStoreState = true;

    ASSERT_ARG(stateID, stateID >= m_backingStoreStateID);
    if (stateID != m_backingStoreStateID) {
        m_backingStoreStateID = stateID;
        m_shouldSendDidUpdateBackingStoreState = true;

        m_webPage->setDeviceScaleFactor(deviceScaleFactor);
        m_webPage->setSize(size);
        m_webPage->layoutIfNeeded();
        m_webPage->scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);

        if (m_layerTreeHost) {
#if USE(COORDINATED_GRAPHICS)
            // Coordinated Graphics sets the size of the root layer to contents size.
            if (!m_webPage->useFixedLayout())
#endif
                m_layerTreeHost->sizeDidChange(m_webPage->size());
        } else
            m_dirtyRegion = m_webPage->bounds();
    } else {
        ASSERT(size == m_webPage->size());
        if (!m_shouldSendDidUpdateBackingStoreState) {
            // We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do.
            m_inUpdateBackingStoreState = false;
            return;
        }
    }

    // The UI process has updated to a new backing store state. Any Update messages we sent before
    // this point will be ignored. We wait to set this to false until after updating the page's
    // size so that any displays triggered by the relayout will be ignored. If we're supposed to
    // respond to the UpdateBackingStoreState message immediately, we'll do a display anyway in
    // sendDidUpdateBackingStoreState; otherwise we shouldn't do one right now.
    m_isWaitingForDidUpdate = false;

    if (respondImmediately) {
        // Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just
        // send back an empty UpdateInfo struct.
        if (m_isPaintingSuspended)
            resumePainting();

        sendDidUpdateBackingStoreState();
    }

    m_inUpdateBackingStoreState = false;
}
Example #3
0
void ChunkedUpdateDrawingArea::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
{
    DrawingAreaID targetDrawingAreaID;
    if (!arguments->decode(CoreIPC::Out(targetDrawingAreaID)))
        return;

    // We can switch drawing areas on the fly, so if this message was targetted at an obsolete drawing area, ignore it.
    if (targetDrawingAreaID != id())
        return;

    switch (messageID.get<DrawingAreaMessage::Kind>()) {
        case DrawingAreaMessage::SetSize: {
            IntSize size;
            if (!arguments->decode(CoreIPC::Out(size)))
                return;

            setSize(size);
            break;
        }
        
        case DrawingAreaMessage::SuspendPainting:
            suspendPainting();
            break;

        case DrawingAreaMessage::ResumePainting: {
            bool forceRepaint;
            if (!arguments->decode(CoreIPC::Out(forceRepaint)))
                return;
            
            resumePainting(forceRepaint);
            break;
        }
        case DrawingAreaMessage::DidUpdate:
            didUpdate();
            break;

        default:
            ASSERT_NOT_REACHED();
            break;
    }
}
void LayerBackedDrawingArea::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
{
    DrawingAreaInfo::Identifier targetIdentifier;
    if (!arguments->decode(CoreIPC::Out(targetIdentifier)))
        return;

    // We can switch drawing areas on the fly, so if this message was targetted at an obsolete drawing area, ignore it.
    if (targetIdentifier != info().identifier)
        return;

    switch (messageID.get<DrawingAreaLegacyMessage::Kind>()) {
        case DrawingAreaLegacyMessage::SetSize: {
            IntSize size;
            if (!arguments->decode(CoreIPC::Out(size)))
                return;

            setSize(size);
            break;
        }
        
        case DrawingAreaLegacyMessage::SuspendPainting:
            suspendPainting();
            break;

        case DrawingAreaLegacyMessage::ResumePainting:
            resumePainting();
            break;

        case DrawingAreaLegacyMessage::DidUpdate:
            didUpdate();
            break;

        default:
            ASSERT_NOT_REACHED();
            break;
    }
}
Example #5
0
void TiledDrawingArea::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
{
    switch (messageID.get<DrawingAreaLegacyMessage::Kind>()) {
    case DrawingAreaLegacyMessage::SetSize: {
        IntSize size;
        if (!arguments->decode(CoreIPC::Out(size)))
            return;

        setSize(size);
        break;
    }
    case DrawingAreaLegacyMessage::SuspendPainting:
        suspendPainting();
        break;
    case DrawingAreaLegacyMessage::ResumePainting:
        resumePainting();
        break;
    case DrawingAreaLegacyMessage::CancelTileUpdate: {
        int tileID;
        if (!arguments->decode(CoreIPC::Out(tileID)))
            return;
        UpdateMap::iterator it = m_pendingUpdates.find(tileID);
        if (it != m_pendingUpdates.end()) {
            m_pendingUpdates.remove(it);
            if (m_pendingUpdates.isEmpty()) {
                WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::AllTileUpdatesProcessed, m_webPage->pageID(), CoreIPC::In());
                m_tileUpdateTimer.stop();
            }
        }
        break;
    }
    case DrawingAreaLegacyMessage::RequestTileUpdate: {
        TileUpdate update;
        if (!arguments->decode(CoreIPC::Out(update.tileID, update.dirtyRect, update.scale)))
            return;
        UpdateMap::iterator it = m_pendingUpdates.find(update.tileID);
        if (it != m_pendingUpdates.end())
            it->second.dirtyRect.unite(update.dirtyRect);
        else {
            m_pendingUpdates.add(update.tileID, update);
            if (!m_tileUpdateTimer.isActive())
                m_tileUpdateTimer.startOneShot(0);
        }
        break;
    }
    case DrawingAreaLegacyMessage::TakeSnapshot: {
        IntSize targetSize;
        IntRect contentsRect;

        if (!arguments->decode(CoreIPC::Out(targetSize, contentsRect)))
            return;

        m_webPage->layoutIfNeeded();

        contentsRect.intersect(IntRect(IntPoint::zero(), m_webPage->mainFrame()->coreFrame()->view()->contentsSize()));

        float targetScale = float(targetSize.width()) / contentsRect.width();

        UpdateChunk updateChunk(IntRect(IntPoint(contentsRect.x() * targetScale, contentsRect.y() * targetScale), targetSize));
        paintIntoUpdateChunk(&updateChunk, targetScale);

        WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::SnapshotTaken, m_webPage->pageID(), CoreIPC::In(updateChunk));
        break;
    }
    default:
        ASSERT_NOT_REACHED();
        break;
    }
}