예제 #1
0
void dumpWebViewAsPixelsAndCompareWithExpected(const char* /*currentTest*/, bool /*forceAllTestsToDumpPixels*/)
{
    RetainPtr<CGContextRef> context = getBitmapContextFromWebView();

#if PLATFORM(MAC)
    if (layoutTestController->testRepaint())
        repaintWebView(context.get(), layoutTestController->testRepaintSweepHorizontally());
    else 
        paintWebView(context.get());

    if (layoutTestController->dumpSelectionRect())
        drawSelectionRect(context.get(), getSelectionRect());
#endif

    // Compute the actual hash to compare to the expected image's hash.
    char actualHash[33];
    getMD5HashStringForBitmap(context.get(), actualHash);
    printf("\nActualHash: %s\n", actualHash);

    // FIXME: We should compare the actualHash to the expected hash here and
    // only set dumpImage to true if they don't match, but DRT doesn't have
    // enough information currently to find the expected checksum file.
    bool dumpImage = true;

    if (dumpImage) {
        RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(context.get()));
        printPNG(image.get());
    }

    printf("#EOF\n");
}
예제 #2
0
	void ChromeClientJS::paint(WebCore::Timer<ChromeClientJS>*)
	{
		webkitTrace();

		if (m_view->m_private->acceleratedContext && m_view->m_private->acceleratedContext->enabled())
			return;

		if(m_dirtyRegion.isEmpty() || !m_view->m_private->backingStore)
			return;

		static const double minimumFrameInterval = 1.0 / 60.0; // No more than 60 frames a second.
		double timeSinceLastDisplay = monotonicallyIncreasingTime() - m_lastDisplayTime;
		double timeUntilNextDisplay = minimumFrameInterval - timeSinceLastDisplay;

		if (timeUntilNextDisplay > 0 && !m_forcePaint) {
			m_displayTimer.startOneShot(timeUntilNextDisplay);
			return;
		}

		m_forcePaint = false;

		Frame& frame = (m_view->m_private->mainFrame->coreFrame()->mainFrame());
		if (!frame.contentRenderer() || !frame.view())
			return;

		frame.view()->updateLayoutAndStyleIfNeededRecursive();
		performAllPendingScrolls();
		paintWebView(m_view, &frame, m_dirtyRegion);

		const IntRect& rect = m_dirtyRegion;

		SDL_Rect offset;

		offset.x = rect.x();
		offset.y = rect.y();
		offset.w = rect.width();
		offset.h = rect.height();

		// Bit blitting is done by locking and unlocking the backstore, we should only do this when
		// we're sure we have a solid backstore surface with no errors.  Part of the problem we may
		// have with this approach is the backstore may only require a small sub-set that needs to be
		// blitted which might be a lot of overhead to send to the screen.  However, there may be
		// use cases where the backstore is not representative of the screen (only the dirtyRegion)
		// in this case we'll have incorrect rendering.  We need to have drawImage and UpperBlit implemented
		// in worker proxies for this to work.
		SDL_UnlockSurface(m_view->m_private->backingStore->widget());
		SDL_LockSurface(m_view->m_private->backingStore->widget());

		m_dirtyRegion = IntRect();
		m_lastDisplayTime = monotonicallyIncreasingTime();
		m_repaintSoonSourceId = 0;
	}
void ChromeClient::paint(WebCore::Timer<ChromeClient>*)
{
    static const double minimumFrameInterval = 1.0 / 60.0; // No more than 60 frames a second.
    double timeSinceLastDisplay = currentTime() - m_lastDisplayTime;
    double timeUntilNextDisplay = minimumFrameInterval - timeSinceLastDisplay;

    if (timeUntilNextDisplay > 0 && !m_forcePaint) {
        m_displayTimer.startOneShot(timeUntilNextDisplay);
        return;
    }

    Frame* frame = core(m_webView)->mainFrame();
    if (!frame || !frame->contentRenderer() || !frame->view())
        return;

    frame->view()->updateLayoutAndStyleIfNeededRecursive();
    performAllPendingScrolls();
    paintWebView(m_webView, frame, m_dirtyRegion);

    HashSet<GtkWidget*> children = m_webView->priv->children;
    HashSet<GtkWidget*>::const_iterator end = children.end();
    for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current) {
        if (static_cast<GtkAllocation*>(g_object_get_data(G_OBJECT(*current), "delayed-allocation"))) {
            gtk_widget_queue_resize_no_redraw(GTK_WIDGET(m_webView));
            break;
        }
    }

    const IntRect& rect = m_dirtyRegion.bounds();
    gtk_widget_queue_draw_area(GTK_WIDGET(m_webView), rect.x(), rect.y(), rect.width(), rect.height());

    m_dirtyRegion = Region();
    m_lastDisplayTime = currentTime();
    m_repaintSoonSourceId = 0;

    // We update the IM context window location here, because we want it to be
    // synced with cursor movement. For instance, a text field can move without
    // the selection changing.
    Frame* focusedFrame = core(m_webView)->focusController()->focusedOrMainFrame();
    if (focusedFrame && focusedFrame->editor().canEdit())
        m_webView->priv->imFilter.setCursorRect(frame->selection()->absoluteCaretBounds());
}