Files
UnrealEngineUWP/Engine/Source/Developer/WebBrowser/Private/WebBrowserViewport.cpp
Matthew Griffin fef7e15bce Adding WebBrowser Developer project
Web Browser project mostly exposes interfaces, hiding all of the CEF3 implementation and technically allowing us to slot in another web system if necessary. Normal process will be to request a browser window interface from the web browser singleton. There is also an implementation of ISlateViewport so that it can be displayed via an SViewport.
The UnrealCEFSubProcess executable is needed for CEF3 to run additional processes for rendering etc. I don't expect this to change very often so it should hopefully just be built once and distributed, since we can't currently specify a program dependency for other modules.
Added a CEF3Utils project to share .dll loading code between web browser and the separate sub process executable.

[CL 2317298 by Matthew Griffin in Main branch]
2014-10-02 10:53:05 -04:00

111 lines
3.4 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "WebBrowserPrivatePCH.h"
#include "WebBrowserViewport.h"
#include "IWebBrowserWindow.h"
FIntPoint FWebBrowserViewport::GetSize() const
{
return (WebBrowserWindow->GetTexture() != nullptr)
? FIntPoint(WebBrowserWindow->GetTexture()->GetWidth(), WebBrowserWindow->GetTexture()->GetHeight())
: FIntPoint();
}
FSlateShaderResource* FWebBrowserViewport::GetViewportRenderTargetTexture() const
{
return WebBrowserWindow->GetTexture();
}
void FWebBrowserViewport::Tick(const FGeometry& AllottedGeometry, double InCurrentTime, float DeltaTime)
{
WebBrowserWindow->SetViewportSize(AllottedGeometry.GetLocalSize());
}
bool FWebBrowserViewport::RequiresVsync() const
{
return false;
}
FCursorReply FWebBrowserViewport::OnCursorQuery( const FGeometry& MyGeometry, const FPointerEvent& CursorEvent )
{
// TODO: retrieve cursor type from WebBrowserWindow if we can figure that out from CefCursorHandle
return FCursorReply::Unhandled();
}
FReply FWebBrowserViewport::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
// Capture mouse on left button down so that you can drag out of the viewport
WebBrowserWindow->OnMouseButtonDown(MyGeometry, MouseEvent);
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton && ViewportWidget.IsValid())
{
return FReply::Handled().CaptureMouse(ViewportWidget.Pin().ToSharedRef());
}
return FReply::Handled();
}
FReply FWebBrowserViewport::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
// Release mouse capture when left button released
WebBrowserWindow->OnMouseButtonUp(MyGeometry, MouseEvent);
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
{
return FReply::Handled().ReleaseMouseCapture();
}
return FReply::Handled();
}
void FWebBrowserViewport::OnMouseEnter(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
}
void FWebBrowserViewport::OnMouseLeave(const FPointerEvent& MouseEvent)
{
}
FReply FWebBrowserViewport::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
WebBrowserWindow->OnMouseMove(MyGeometry, MouseEvent);
return FReply::Handled();
}
FReply FWebBrowserViewport::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
WebBrowserWindow->OnMouseWheel(MyGeometry, MouseEvent);
return FReply::Handled();
}
FReply FWebBrowserViewport::OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent)
{
WebBrowserWindow->OnMouseButtonDoubleClick(InMyGeometry, InMouseEvent);
return FReply::Handled();
}
FReply FWebBrowserViewport::OnKeyDown(const FGeometry& MyGeometry, const FKeyboardEvent& InKeyboardEvent)
{
WebBrowserWindow->OnKeyDown(InKeyboardEvent);
return FReply::Handled();
}
FReply FWebBrowserViewport::OnKeyUp(const FGeometry& MyGeometry, const FKeyboardEvent& InKeyboardEvent)
{
WebBrowserWindow->OnKeyUp(InKeyboardEvent);
return FReply::Handled();
}
FReply FWebBrowserViewport::OnKeyChar( const FGeometry& MyGeometry, const FCharacterEvent& InCharacterEvent )
{
WebBrowserWindow->OnKeyChar(InCharacterEvent);
return FReply::Handled();
}
FReply FWebBrowserViewport::OnKeyboardFocusReceived(const FKeyboardFocusEvent& InKeyboardFocusEvent)
{
WebBrowserWindow->OnFocus(true);
return FReply::Handled();
}
void FWebBrowserViewport::OnKeyboardFocusLost(const FKeyboardFocusEvent& InKeyboardFocusEvent)
{
WebBrowserWindow->OnFocus(false);
}