void wxWebView::OnPaint(wxPaintEvent& event) { if (m_beingDestroyed || !m_mainFrame) return; WebCore::Frame* frame = m_mainFrame->GetFrame(); if (!frame || !frame->view()) return; wxAutoBufferedPaintDC dc(this); if (IsShown() && frame->document()) { #if USE(WXGC) wxGCDC gcdc(dc); #endif if (dc.IsOk()) { wxRect paintRect = GetUpdateRegion().GetBox(); #if USE(WXGC) WebCore::GraphicsContext gc(&gcdc); #else WebCore::GraphicsContext gc(&dc); #endif if (frame->contentRenderer()) { frame->view()->layoutIfNeededRecursive(); frame->view()->paint(&gc, paintRect); } } } }
void BWebPage::paint(BRect rect, bool immediate) { if (fLayoutingView || !rect.IsValid()) return; // Block any drawing as long as the BWebView is hidden // (should be extended to when the containing BWebWindow is not // currently on screen either...) if (!fPageVisible) { fPageDirty = true; return; } // NOTE: fMainFrame can be 0 because init() eventually ends up calling // paint()! BWebFrame seems to cause an initial page to be loaded, maybe // this ought to be avoided also for start-up speed reasons! if (!fMainFrame) return; WebCore::Frame* frame = fMainFrame->Frame(); WebCore::FrameView* view = frame->view(); if (!view || !frame->contentRenderer()) return; // Since calling layoutIfNeededRecursive can cycle back into paint(), // call this method before locking the window and before holding the // offscreen view lock. fLayoutingView = true; view->layout(true); fLayoutingView = false; if (!fWebView->LockLooper()) return; BView* offscreenView = fWebView->OffscreenView(); // Lock the offscreen bitmap while we still have the // window locked. This cannot deadlock and makes sure // the window is not deleting the offscreen view right // after we unlock it and before locking the bitmap. if (!offscreenView->LockLooper()) { fWebView->UnlockLooper(); return; } fWebView->UnlockLooper(); if (!rect.IsValid()) rect = offscreenView->Bounds(); BRegion region(rect); internalPaint(offscreenView, view, ®ion); offscreenView->UnlockLooper(); fPageDirty = false; // Notify the window that it can now pull the bitmap in its own thread fWebView->SetOffscreenViewClean(rect, immediate); }
void WebView::OnPaint(wxPaintEvent& event) { if (m_beingDestroyed || !m_mainFrame) return; WebCore::Frame* frame = m_mainFrame->GetFrame(); if (!frame || !frame->view()) return; // we can't use wxAutoBufferedPaintDC here because it will not create // a 32-bit bitmap for its buffer. #if __WXMSW__ wxPaintDC paintdc(this); int width, height; paintdc.GetSize(&width, &height); wxBitmap bitmap(width, height, 32); wxMemoryDC dc(bitmap); #else wxPaintDC dc(this); #endif if (IsShown() && frame->document()) { #if USE(WXGC) #if wxCHECK_VERSION(2, 9, 2) && defined(wxUSE_CAIRO) && wxUSE_CAIRO wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer(); if (!renderer) renderer = wxGraphicsRenderer::GetDefaultRenderer(); wxGraphicsContext* context = renderer->CreateContext(dc); wxGCDC gcdc(context); #else wxGCDC gcdc(dc); #endif #endif if (dc.IsOk()) { wxRect paintRect = GetUpdateRegion().GetBox(); #if USE(WXGC) WebCore::GraphicsContext gc(&gcdc); #else WebCore::GraphicsContext gc(&dc); #endif if (frame->contentRenderer()) { frame->view()->updateLayoutAndStyleIfNeededRecursive(); frame->view()->paint(&gc, paintRect); #if __WXMSW__ dc.SelectObject(wxNullBitmap); paintdc.DrawBitmap(bitmap, 0, 0); #endif } } } }
void wxWebView::OnPaint(wxPaintEvent& event) { if (m_beingDestroyed || !m_mainFrame) return; WebCore::Frame* frame = m_mainFrame->GetFrame(); if (!frame || !frame->view()) return; wxAutoBufferedPaintDC dc(this); if (IsShown() && frame->document()) { #if USE(WXGC) wxGCDC gcdc(dc); #endif if (dc.IsOk()) { wxRect paintRect = GetUpdateRegion().GetBox(); WebCore::IntSize offset = frame->view()->scrollOffset(); #if USE(WXGC) gcdc.SetDeviceOrigin(-offset.width(), -offset.height()); #endif dc.SetDeviceOrigin(-offset.width(), -offset.height()); paintRect.Offset(offset.width(), offset.height()); #if USE(WXGC) WebCore::GraphicsContext* gc = new WebCore::GraphicsContext(&gcdc); #else WebCore::GraphicsContext* gc = new WebCore::GraphicsContext((wxWindowDC*)&dc); #endif if (gc && frame->contentRenderer()) { if (frame->view()->needsLayout()) frame->view()->layout(); frame->view()->paintContents(gc, paintRect); } delete gc; } } }
static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event) { WebCore::Frame* frame = core(webView_s->mainFrame()); if (frame->contentRenderer() && frame->view()) { frame->view()->layoutIfNeededRecursive(); cairo_t* cr = gdk_cairo_create(event->window); GraphicsContext ctx(cr); cairo_destroy(cr); ctx.setGdkExposeEvent(event); GOwnPtr<GdkRectangle> rects; int rectCount; gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount); // Avoid recursing into the render tree excessively bool coalesce = shouldCoalesce(event->area, rects.get(), rectCount); if (coalesce) { IntRect rect = event->area; ctx.clip(rect); if (webView_s->transparent()) ctx.clearRect(rect); frame->view()->paint(&ctx, rect); } else { for (int i = 0; i < rectCount; i++) { IntRect rect = rects.get()[i]; ctx.save(); ctx.clip(rect); if (webView_s->transparent()) ctx.clearRect(rect); frame->view()->paint(&ctx, rect); ctx.restore(); } } } return false; }
void wxWebView::OnPaint(wxPaintEvent& event) { if (m_beingDestroyed || !m_mainFrame) return; // WebView active state is based on TLW active state. wxTopLevelWindow* tlw = dynamic_cast<wxTopLevelWindow*>(wxGetTopLevelParent(this)); if (tlw && tlw->IsActive()) m_impl->page->focusController()->setActive(true); else { m_impl->page->focusController()->setActive(false); } WebCore::Frame* frame = m_mainFrame->GetFrame(); if (!frame || !frame->view()) return; wxAutoBufferedPaintDC dc(this); if (IsShown() && frame->document()) { #if USE(WXGC) wxGCDC gcdc(dc); #endif if (dc.IsOk()) { wxRect paintRect = GetUpdateRegion().GetBox(); #if USE(WXGC) WebCore::GraphicsContext gc(&gcdc); #else WebCore::GraphicsContext gc(&dc); #endif if (frame->contentRenderer()) { frame->view()->layoutIfNeededRecursive(); frame->view()->paint(&gc, paintRect); } } } }