Example #1
0
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);
            }
        }
    }
}
Example #2
0
void WebView::OnSize(wxSizeEvent& event)
{ 
    if (m_isInitialized && m_mainFrame) {
        WebCore::Frame* frame = m_mainFrame->GetFrame();
        frame->view()->resize(event.GetSize());
        frame->view()->adjustViewSize();
    }
      
    event.Skip();
}
Example #3
0
void wxWebView::OnSize(wxSizeEvent& event)
{ 
    if (m_isInitialized && m_mainFrame) {
        WebCore::Frame* frame = m_mainFrame->GetFrame();
        frame->view()->setFrameRect(wxRect(wxPoint(0,0), event.GetSize()));
        frame->view()->forceLayout();
        frame->view()->adjustViewSize();
    }
      
    event.Skip();
}
Example #4
0
static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
{
    GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget,allocation);

    //WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);

    WebCore::Frame* frame = core(webView_s->mainFrame());
    frame->view()->resize(allocation->width, allocation->height);
    frame->view()->forceLayout();
    frame->view()->adjustViewSize();
}
Example #5
0
void wxWebView::SetTransparent(bool transparent)
{
    WebCore::Frame* frame = 0;
    if (m_mainFrame)
        frame = m_mainFrame->GetFrame();
    
    if (!frame || !frame->view())
        return;

    frame->view()->setTransparent(transparent);
}
Example #6
0
bool wxWebView::IsTransparent() const
{
    WebCore::Frame* frame = 0;
    if (m_mainFrame)
        frame = m_mainFrame->GetFrame();

   if (!frame || !frame->view())
        return false;

    return frame->view()->isTransparent();
}
Example #7
0
void wxWebView::OnSize(wxSizeEvent& event)
{ 
    if (m_isInitialized && m_mainFrame) {
        WebCore::Frame* frame = m_mainFrame->GetFrame();
        frame->eventHandler()->sendResizeEvent();
        frame->view()->layout();
        frame->view()->adjustScrollbars();
    }
      
    event.Skip();
}
Example #8
0
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
            }
        }
    }
}
Example #9
0
WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
{
    guint context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
    GOwnPtr<char> linkURI(0);
    GOwnPtr<char> imageURI(0);
    GOwnPtr<char> mediaURI(0);
    WebKitDOMNode* node = 0;
    WebCore::Frame* targetFrame;
    WebCore::IntPoint point;

    if (!result.absoluteLinkURL().isEmpty()) {
        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
        linkURI.set(g_strdup(result.absoluteLinkURL().string().utf8().data()));
    }

    if (!result.absoluteImageURL().isEmpty()) {
        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
        imageURI.set(g_strdup(result.absoluteImageURL().string().utf8().data()));
    }

    if (!result.absoluteMediaURL().isEmpty()) {
        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
        mediaURI.set(g_strdup(result.absoluteMediaURL().string().utf8().data()));
    }

    if (result.isSelected())
        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION;

    if (result.isContentEditable())
        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;

    if (result.innerNonSharedNode())
        node = kit(result.innerNonSharedNode());

    targetFrame = result.targetFrame();
    if (targetFrame && targetFrame->view()) {
        // Convert document coords to widget coords.
        point = targetFrame->view()->contentsToWindow(result.point());
    } else
        point = result.point();

    return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
                                               "link-uri", linkURI.get(),
                                               "image-uri", imageURI.get(),
                                               "media-uri", mediaURI.get(),
                                               "context", context,
                                               "inner-node", node,
                                               "x", point.x(),
                                               "y", point.y(),
                                               NULL));
}
Example #10
0
void wxWebView::OnMouseEvents(wxMouseEvent& event)
{
    event.Skip();
    
    if (!m_mainFrame)
        return; 
        
    WebCore::Frame* frame = m_mainFrame->GetFrame();  
    if (!frame || !frame->view())
        return;
    
    wxPoint globalPoint = ClientToScreen(event.GetPosition());

    wxEventType type = event.GetEventType();
    
    if (type == wxEVT_MOUSEWHEEL) {
        WebCore::PlatformWheelEvent wkEvent(event, globalPoint);
        frame->eventHandler()->handleWheelEvent(wkEvent);
        return;
    }
    
    WebCore::PlatformMouseEvent wkEvent(event, globalPoint);

    if (type == wxEVT_LEFT_DOWN || type == wxEVT_MIDDLE_DOWN || type == wxEVT_RIGHT_DOWN || 
                type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK)
        frame->eventHandler()->handleMousePressEvent(wkEvent);
    
    else if (type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_UP)
        frame->eventHandler()->handleMouseReleaseEvent(wkEvent);

    else if (type == wxEVT_MOTION)
        frame->eventHandler()->mouseMoved(wkEvent);
}
Example #11
0
void wxWebView::OnContextMenuEvents(wxContextMenuEvent& event)
{
    m_impl->page->contextMenuController()->clearContextMenu();
    wxPoint localEventPoint = ScreenToClient(event.GetPosition());

    if (!m_mainFrame)
        return;
        
    WebCore::Frame* focusedFrame = m_mainFrame->GetFrame();
    if (!focusedFrame->view())
        return;

    //Create WebCore mouse event from the wxContextMenuEvent
    wxMouseEvent mouseEvent(wxEVT_RIGHT_DOWN);
    mouseEvent.m_x = localEventPoint.x;
    mouseEvent.m_y = localEventPoint.y;
    WebCore::PlatformMouseEvent wkEvent(mouseEvent, event.GetPosition());

    bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(wkEvent);
    if (!handledEvent)
        return;

    WebCore::ContextMenu* coreMenu = m_impl->page->contextMenuController()->contextMenu();
    if (!coreMenu)
        return;

    WebCore::PlatformMenuDescription menuWx = coreMenu->platformDescription();
    if (!menuWx)
        return;

    PopupMenu(menuWx, localEventPoint);
}
Example #12
0
void wxWebView::OnContextMenuEvents(wxContextMenuEvent& event)
{
    Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxWebView::OnMenuSelectEvents), NULL, this);
    m_impl->page->contextMenuController()->clearContextMenu();
    wxPoint localEventPoint = ScreenToClient(event.GetPosition());

    if (!m_impl->page)
        return;
        
    WebCore::Frame* focusedFrame = m_impl->page->focusController()->focusedOrMainFrame();
    if (!focusedFrame->view())
        return;

    //Create WebCore mouse event from the wxContextMenuEvent
    wxMouseEvent mouseEvent(wxEVT_RIGHT_DOWN);
    mouseEvent.m_x = localEventPoint.x;
    mouseEvent.m_y = localEventPoint.y;
    WebCore::PlatformMouseEvent wkEvent(mouseEvent, event.GetPosition(), 1);

    bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(wkEvent);
    if (!handledEvent)
        return;

    WebCore::ContextMenu* coreMenu = m_impl->page->contextMenuController()->contextMenu();
    if (!coreMenu)
        return;

    WebCore::PlatformMenuDescription menuWx = coreMenu->platformDescription();
    if (!menuWx)
        return;

    PopupMenu(menuWx, localEventPoint);
    
    Disconnect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxWebView::OnMenuSelectEvents), NULL, this);
}
Example #13
0
static void printFrames(const WebCore::Frame& frame, const WebCore::Frame* targetFrame, int indent)
{
    if (&frame == targetFrame) {
        printf("--> ");
        printIndent(indent - 1);
    } else
        printIndent(indent);

    WebCore::FrameView* view = frame.view();
    printf("Frame %p %dx%d\n", &frame, view ? view->width() : 0, view ? view->height() : 0);
    printIndent(indent);
    printf("  ownerElement=%p\n", frame.ownerElement());
    printIndent(indent);
    printf("  frameView=%p (needs layout %d)\n", view, view ? view->needsLayout() : false);
    printIndent(indent);
    printf("  renderView=%p\n", view ? view->renderView() : nullptr);
    printIndent(indent);
    printf("  ownerRenderer=%p\n", frame.ownerRenderer());
    printIndent(indent);
    printf("  document=%p (needs style recalc %d)\n", frame.document(), frame.document() ? frame.document()->childNeedsStyleRecalc() : false);
    printIndent(indent);
    printf("  uri=%s\n", frame.document()->documentURI().utf8().data());

    for (WebCore::Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling())
        printFrames(*child, targetFrame, indent + 1);
}
Example #14
0
void DumpRenderTreeSupportQt::setMediaType(QWebFrame* frame, const QString& type)
{
    WebCore::Frame* coreFrame = QWebFramePrivate::core(frame);
    WebCore::FrameView* view = coreFrame->view();
    view->setMediaType(type);
    coreFrame->document()->styleSelectorChanged(RecalcStyleImmediately);
    view->layout();
}
Example #15
0
void InspectorClientQt::hideHighlight()
{
    WebCore::Frame* frame = m_inspectedWebPage->page->mainFrame();
    if (frame) {
        QRect rect = m_inspectedWebPage->mainFrameAdapter()->frameRect();
        if (!rect.isEmpty())
            frame->view()->invalidateRect(rect);
    }
}
Example #16
0
void BWebPage::handleMouseWheelChanged(BMessage* message)
{
    WebCore::Frame* frame = fMainFrame->Frame();
    if (!frame->view() || !frame->document())
        return;

    PlatformWheelEvent event(message);
    frame->eventHandler()->handleWheelEvent(event);
}
Example #17
0
void BWebPage::scroll(int xOffset, int yOffset, const BRect& rectToScroll,
	const BRect& clipRect)
{
    if (!fWebView->LockLooper())
        return;
    BBitmap* bitmap = fWebView->OffscreenBitmap();
    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 (!bitmap->Lock()) {
    	fWebView->UnlockLooper();
    	return;
    }
    fWebView->UnlockLooper();

	BRect clip = offscreenView->Bounds();
	if (clipRect.IsValid())
		clip = clip & clipRect;
	BRect rectAtSrc = rectToScroll;
	BRect rectAtDst = rectAtSrc.OffsetByCopy(xOffset, yOffset);
	BRegion repaintRegion(rectAtSrc);
	if (clip.Intersects(rectAtSrc) && clip.Intersects(rectAtDst)) {
		// clip source rect
		rectAtSrc = rectAtSrc & clip;
		// clip dest rect
		rectAtDst = rectAtDst & clip;
		// move dest back over source and clip source to dest
		rectAtDst.OffsetBy(-xOffset, -yOffset);
		rectAtSrc = rectAtSrc & rectAtDst;
		// remember the part that will be clean
		rectAtDst.OffsetBy(xOffset, yOffset);
		repaintRegion.Exclude(rectAtDst);

		offscreenView->CopyBits(rectAtSrc, rectAtDst);
	}

	if (repaintRegion.Frame().IsValid()) {
        WebCore::Frame* frame = fMainFrame->Frame();
        WebCore::FrameView* view = frame->view();
        // Make sure the view is layouted, since it will refuse to paint
        // otherwise.
        fLayoutingView = true;
        view->layout(true);
        fLayoutingView = false;

		internalPaint(offscreenView, view, &repaintRegion);
	}

    bitmap->Unlock();

    // Notify the view that it can now pull the bitmap in its own thread
    fWebView->SetOffscreenViewClean(rectToScroll, false);
}
Example #18
0
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, &region);

    offscreenView->UnlockLooper();

    fPageDirty = false;

    // Notify the window that it can now pull the bitmap in its own thread
    fWebView->SetOffscreenViewClean(rect, immediate);
}
Example #19
0
void wxWebView::OnMouseEvents(wxMouseEvent& event)
{
    event.Skip();
    
    if (!m_impl->page)
        return; 
        
    WebCore::Frame* frame = m_mainFrame->GetFrame();  
    if (!frame || !frame->view())
        return;
    
    wxPoint globalPoint = ClientToScreen(event.GetPosition());

    wxEventType type = event.GetEventType();
    
    if (type == wxEVT_MOUSEWHEEL) {
        if (m_mouseWheelZooms && event.ControlDown() && !event.AltDown() && !event.ShiftDown()) {
            if (event.GetWheelRotation() < 0)
                DecreaseTextSize();
            else if (event.GetWheelRotation() > 0)
                IncreaseTextSize();
        } else {
            WebCore::PlatformWheelEvent wkEvent(event, globalPoint);
            frame->eventHandler()->handleWheelEvent(wkEvent);
        }

        return;
    }
    
    int clickCount = event.ButtonDClick() ? 2 : 1;

    if (clickCount == 1 && m_impl->tripleClickTimer.IsRunning()) {
        wxPoint diff(event.GetPosition() - m_impl->tripleClickPos);
        if (abs(diff.x) <= wxSystemSettings::GetMetric(wxSYS_DCLICK_X) &&
            abs(diff.y) <= wxSystemSettings::GetMetric(wxSYS_DCLICK_Y)) {
            clickCount = 3;
        }
    } else if (clickCount == 2) {
        m_impl->tripleClickTimer.Start(getDoubleClickTime(), false);
        m_impl->tripleClickPos = event.GetPosition();
    }
    
    WebCore::PlatformMouseEvent wkEvent(event, globalPoint, clickCount);

    if (type == wxEVT_LEFT_DOWN || type == wxEVT_MIDDLE_DOWN || type == wxEVT_RIGHT_DOWN || 
                type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK) {
        frame->eventHandler()->handleMousePressEvent(wkEvent);
        if (!HasCapture())
            CaptureMouse();
    } else if (type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_UP) {
        frame->eventHandler()->handleMouseReleaseEvent(wkEvent);
        while (HasCapture())
            ReleaseMouse();
    } else if (type == wxEVT_MOTION || type == wxEVT_ENTER_WINDOW || type == wxEVT_LEAVE_WINDOW)
        frame->eventHandler()->mouseMoved(wkEvent);
}
Example #20
0
void BWebPage::handleFrameResized(const BMessage* message)
{
    float width;
    float height;
    message->FindFloat("width", &width);
    message->FindFloat("height", &height);

    WebCore::Frame* frame = fMainFrame->Frame();
    frame->view()->resize(width + 1, height + 1);
}
Example #21
0
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;
        }
    }
}
Example #22
0
void BWebPage::handleKeyEvent(BMessage* message)
{
    WebCore::Frame* frame = fPage->focusController()->focusedOrMainFrame();
    if (!frame->view() || !frame->document())
        return;

    PlatformKeyboardEvent event(message);
	// Try to let WebCore handle this event
	if (!frame->eventHandler()->keyEvent(event) && message->what == B_KEY_DOWN) {
		// Handle keyboard scrolling (probably should be extracted to a method.)
		ScrollDirection direction;
		ScrollGranularity granularity;
		BString bytes = message->FindString("bytes");
		switch (bytes.ByteAt(0)) {
			case B_UP_ARROW:
				granularity = ScrollByLine;
				direction = ScrollUp;
				break;
			case B_DOWN_ARROW:
				granularity = ScrollByLine;
				direction = ScrollDown;
				break;
			case B_LEFT_ARROW:
				granularity = ScrollByLine;
				direction = ScrollLeft;
				break;
			case B_RIGHT_ARROW:
				granularity = ScrollByLine;
				direction = ScrollRight;
				break;
			case B_HOME:
				granularity = ScrollByDocument;
				direction = ScrollUp;
				break;
			case B_END:
				granularity = ScrollByDocument;
				direction = ScrollDown;
				break;
			case B_PAGE_UP:
				granularity = ScrollByPage;
				direction = ScrollUp;
				break;
			case B_PAGE_DOWN:
				granularity = ScrollByPage;
				direction = ScrollDown;
				break;
			default:
				return;
		}
		frame->eventHandler()->scrollRecursively(direction, granularity);
	}
}
Example #23
0
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;
}
Example #24
0
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);
            }
        }
    }
}
Example #25
0
void DumpRenderTreeSupportEfl::layoutFrame(Evas_Object* ewkFrame)
{
    WebCore::Frame* frame = EWKPrivate::coreFrame(ewkFrame);

    if (!frame)
        return;

    WebCore::FrameView* frameView = frame->view();

    if (!frameView)
        return;

    frameView->layout();
}
Example #26
0
String DumpRenderTreeSupportEfl::renderTreeDump(Evas_Object* ewkFrame)
{
    WebCore::Frame* frame = EWKPrivate::coreFrame(ewkFrame);

    if (!frame)
        return String();

    WebCore::FrameView *frameView = frame->view();

    if (frameView && frameView->layoutPending())
        frameView->layout();

    return WebCore::externalRepresentation(frame);
}
Example #27
0
void BWebPage::handleMouseEvent(const BMessage* message)
{
    WebCore::Frame* frame = fMainFrame->Frame();
    if (!frame->view() || !frame->document())
        return;

    PlatformMouseEvent event(message);
    switch (message->what) {
    case B_MOUSE_DOWN:
        // Handle context menus, if necessary.
        if (event.button() == RightButton) {
            fPage->contextMenuController()->clearContextMenu();

            WebCore::Frame* focusedFrame = fPage->focusController()->focusedOrMainFrame();
            focusedFrame->eventHandler()->sendContextMenuEvent(event);
            // If the web page implements it's own context menu handling, then
            // the contextMenu() pointer will be zero. In this case, we should
            // also swallow the event.
            ContextMenu* contextMenu = fPage->contextMenuController()->contextMenu();
            if (contextMenu) {
            	BMenu* platformMenu = contextMenu->releasePlatformDescription();
            	if (platformMenu) {
            		// Need to convert the BMenu into BPopUpMenu.
	            	BPopUpMenu* popupMenu = new BPopUpMenu("context menu");
					for (int32 i = platformMenu->CountItems() - 1; i >= 0; i--) {
					    BMenuItem* item = platformMenu->RemoveItem(i);
					    popupMenu->AddItem(item, 0);
					}
					BPoint screenLocation(event.globalPosition().x() + 2,
					    event.globalPosition().y() + 2);
            	    popupMenu->Go(screenLocation, true, true, true);
            	    delete platformMenu;
            	}
            }
            break;
    	}
    	// Handle regular mouse events.
        frame->eventHandler()->handleMousePressEvent(event);
        break;
    case B_MOUSE_UP:
        frame->eventHandler()->handleMouseReleaseEvent(event);
        break;
    case B_MOUSE_MOVED:
    default:
        frame->eventHandler()->mouseMoved(event);
        break;
    }
}
Example #28
0
void wxWebView::OnKeyEvents(wxKeyEvent& event)
{
    WebCore::Frame* frame = 0;
    if (m_mainFrame)
        frame = m_mainFrame->GetFrame();
        
    if (frame && frame->view()) {
        // WebCore doesn't handle these events itself, so we need to do
        // it and not send the event down or else CTRL+C will erase the text
        // and replace it with c.
        if (event.CmdDown() && event.GetEventType() == wxEVT_KEY_UP) {
            if (event.GetKeyCode() == static_cast<int>('C'))
                Copy();
            else if (event.GetKeyCode() == static_cast<int>('X'))
                Cut();
            else if (event.GetKeyCode() == static_cast<int>('V'))
                Paste();
            else if (event.GetKeyCode() == static_cast<int>('Z')) {
                if (event.ShiftDown()) {
                    if (m_mainFrame->CanRedo())
                        m_mainFrame->Redo();
                }
                else {
                    if (m_mainFrame->CanUndo())
                        m_mainFrame->Undo();
                }
            }
        } else {    
            WebCore::PlatformKeyboardEvent wkEvent(event);
            if (wkEvent.type() == WebCore::PlatformKeyboardEvent::Char && wkEvent.altKey())
                frame->eventHandler()->handleAccessKey(wkEvent);
            else
                frame->eventHandler()->keyEvent(wkEvent);
        }
    }
    
    // make sure we get the character event.
    if (event.GetEventType() != wxEVT_CHAR)
        event.Skip();
}
Example #29
0
static void printFrames(const WebCore::Frame& frame, const WebCore::Frame* targetFrame, int indent)
{
    if (&frame == targetFrame) {
        printf("--> ");
        printIndent(indent - 1);
    } else
        printIndent(indent);

    WebCore::FrameView* view = frame.view();
    printf("Frame %p %dx%d\n", &frame, view ? view->width() : 0, view ? view->height() : 0);
    printIndent(indent);
    printf("  ownerElement=%p\n", frame.ownerElement());
    printIndent(indent);
    printf("  frameView=%p\n", view);
    printIndent(indent);
    printf("  document=%p\n", frame.document());
    printIndent(indent);
    printf("  uri=%s\n\n", frame.document()->documentURI().utf8().data());

    for (WebCore::Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling())
        printFrames(*child, targetFrame, indent + 1);
}
WebCore::IntRect InjectedBundleHitTestResult::imageRect() const
{
    WebCore::IntRect imageRect = m_hitTestResult.imageRect();
    if (imageRect.isEmpty())
        return imageRect;
        
    // The image rect in WebCore::HitTestResult is in frame coordinates, but we need it in WKView
    // coordinates since WebKit2 clients don't have enough context to do the conversion themselves.
    WebFrame* webFrame = frame();
    if (!webFrame)
        return imageRect;
    
    WebCore::Frame* coreFrame = webFrame->coreFrame();
    if (!coreFrame)
        return imageRect;
    
    WebCore::FrameView* view = coreFrame->view();
    if (!view)
        return imageRect;
    
    return view->contentsToRootView(imageRect);
}