Ejemplo n.º 1
0
void TiledBackingStore::adjustVisibleRect()
{
    IntRect visibleRect = visibleContentsRect();
    if (m_previousVisibleRect == visibleRect)
        return;
    m_previousVisibleRect = visibleRect;

    startTileCreationTimer();
}
Ejemplo n.º 2
0
void WebViewNix::didChangeContentPosition(const WebCore::FloatPoint& trajectoryVector)
{
    DrawingAreaProxy* drawingArea = page()->drawingArea();
    if (!drawingArea)
        return;
    FloatRect visibleContentsRect(contentPosition(), visibleContentsSize());
    visibleContentsRect.intersect(FloatRect(FloatPoint(), contentsSize()));
    drawingArea->setVisibleContentsRect(visibleContentsRect, trajectoryVector);
}
Ejemplo n.º 3
0
void WebView::updateViewportSize()
{
    if (CoordinatedDrawingAreaProxy* drawingArea = static_cast<CoordinatedDrawingAreaProxy*>(page()->drawingArea())) {
        // Web Process expects sizes in UI units, and not raw device units.
        drawingArea->setSize(roundedIntSize(dipSize()), IntSize(), IntSize());
        FloatRect visibleContentsRect(contentPosition(), visibleContentsSize());
        visibleContentsRect.intersect(FloatRect(FloatPoint(), contentsSize()));
        drawingArea->setVisibleContentsRect(visibleContentsRect, FloatPoint());
    }
}
Ejemplo n.º 4
0
void TiledBackingStore::coverWithTilesIfNeeded(const FloatPoint& panningTrajectoryVector)
{
    IntRect visibleRect = visibleContentsRect();
    if (m_visibleRectTrajectoryVector == panningTrajectoryVector && m_previousVisibleRect == visibleRect)
        return;

    m_visibleRectTrajectoryVector = panningTrajectoryVector;
    m_previousVisibleRect = visibleRect;

    startTileCreationTimer();
}
Ejemplo n.º 5
0
void PageViewportController::syncVisibleContents(const FloatPoint& trajectoryVector)
{
    DrawingAreaProxy* const drawingArea = m_webPageProxy->drawingArea();
    if (!drawingArea || m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
        return;

    FloatRect visibleContentsRect(clampViewportToContents(m_viewportPos, m_effectiveScale), viewportSizeInContentsCoordinates());
    visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize));
    drawingArea->setVisibleContentsRect(visibleContentsRect, m_effectiveScale, trajectoryVector);

    m_client->didChangeVisibleContents();
}
Ejemplo n.º 6
0
void QtViewportHandler::informVisibleContentChange(const QPointF& trajectoryVector)
{
    DrawingAreaProxy* drawingArea = m_webPageProxy->drawingArea();
    if (!drawingArea)
        return;

    if (m_lastVisibleContentsRect == visibleContentsRect())
        return;

    qreal scale = m_pageItem->contentsScale();

    if (scale != m_lastCommittedScale)
        emit m_viewportItem->experimental()->test()->contentsScaleCommitted();
    m_lastCommittedScale = scale;
    m_lastVisibleContentsRect = visibleContentsRect();

    drawingArea->setVisibleContentsRect(visibleContentsRect(), scale, trajectoryVector, m_viewportItem->contentPos());

    // Ensure that updatePaintNode is always called before painting.
    m_pageItem->update();
}
Ejemplo n.º 7
0
void TiledBackingStore::removeAllNonVisibleTiles()
{
    dropTilesOutsideRect(visibleContentsRect());
}
Ejemplo n.º 8
0
void TiledBackingStore::createTiles()
{
    if (m_contentsFrozen)
        return;
    
    IntRect visibleRect = visibleContentsRect();
    m_previousVisibleRect = visibleRect;

    if (visibleRect.isEmpty())
        return;

    // Resize tiles on edges in case the contents size has changed.
    bool didResizeTiles = resizeEdgeTiles();

    IntRect keepRect;
    IntRect coverRect;
    computeCoverAndKeepRect(visibleRect, coverRect, keepRect);

    dropTilesOutsideRect(keepRect);
    
    // Search for the tile position closest to the viewport center that does not yet contain a tile. 
    // Which position is considered the closest depends on the tileDistance function.
    double shortestDistance = std::numeric_limits<double>::infinity();
    Vector<Tile::Coordinate> tilesToCreate;
    unsigned requiredTileCount = 0;

    Tile::Coordinate topLeft = tileCoordinateForPoint(coverRect.location());
    Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(coverRect));
    for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
        for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
            Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
            if (tileAt(currentCoordinate))
                continue;
            ++requiredTileCount;
            // Distance is 0 for all tiles inside the visibleRect.
            double distance = tileDistance(visibleRect, currentCoordinate);
            if (distance > shortestDistance)
                continue;
            if (distance < shortestDistance) {
                tilesToCreate.clear();
                shortestDistance = distance;
            }
            tilesToCreate.append(currentCoordinate);
        }
    }

    // Now construct the tile(s) within the shortest distance.
    unsigned tilesToCreateCount = tilesToCreate.size();
    for (unsigned n = 0; n < tilesToCreateCount; ++n) {
        Tile::Coordinate coordinate = tilesToCreate[n];
        setTile(coordinate, m_backend->createTile(this, coordinate));
    }
    requiredTileCount -= tilesToCreateCount;

    // Paint the content of the newly created tiles.
    if (tilesToCreateCount || didResizeTiles)
        updateTileBuffers();

    // Re-call createTiles on a timer to cover the visible area with the newest shortest distance.
    if (requiredTileCount)
        m_tileCreationTimer->startOneShot(m_tileCreationDelay);
}
Ejemplo n.º 9
0
bool TiledBackingStore::visibleAreaIsCovered() const
{
    return coverageRatio(visibleContentsRect()) == 1.0f;
}
Ejemplo n.º 10
0
IntRect TiledBackingStore::visibleRect() const
{
    return mapFromContents(visibleContentsRect());
}