You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* Untangle mutual dependencies between objects and constructor order (OPP-3858): * FWebBrowserWindow no longer keeps a reference to FWebBrowserHandler. * CefBrowserWindow is created before creating FWebBrowserWindow and passed to its constructor. * FWebBrowserViewport no longer has a reference back to the viewport widget. * Cleaned how some platform specific paths were defined during module initialization. * Sets current thread name (back) to GameThread after initializing CEF (UE-5165) * Adopted changes from UT (with some modifications): * Enable on-disk caching and persisting cookies when requested by server. * Added product name and engine version to user agent request header. * Ensure UStruct parameters passed by value to FWebJSFunctions are copied when constructing the argument list and not just their address. *SWebBrowser scripting: Add support for passing TMap<FString, T> to FWebJSFunction objects. Note: since the struct serializer does not yet support maps, this only works for arguments passed directly to the function object and not UStruct members nor function return values. OPP-3861 * Add support for passing a reference to the JS promise object implicitly created when calling UFunctions to provide for a way to report runtime errors back to it instead of just passing the return value. * This also allows for implementing async functionality as the promise object can be saved and used after the UFunction has returned. Merging CL#2633955, CL#2634077, CL#2634226, CL#2635540, CL#2636167, and CL#2636262 using UE4-To-UE4-LauncherDev [CL 2636308 by Keli Hlodversson in Main branch]
121 lines
3.8 KiB
C++
121 lines
3.8 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "WebBrowserPrivatePCH.h"
|
|
#include "WebBrowserViewport.h"
|
|
#include "IWebBrowserWindow.h"
|
|
|
|
FIntPoint FWebBrowserViewport::GetSize() const
|
|
{
|
|
return (WebBrowserWindow->GetTexture(bIsPopup) != nullptr)
|
|
? FIntPoint(WebBrowserWindow->GetTexture(bIsPopup)->GetWidth(), WebBrowserWindow->GetTexture(bIsPopup)->GetHeight())
|
|
: FIntPoint();
|
|
}
|
|
|
|
FSlateShaderResource* FWebBrowserViewport::GetViewportRenderTargetTexture() const
|
|
{
|
|
return WebBrowserWindow->GetTexture(bIsPopup);
|
|
}
|
|
|
|
void FWebBrowserViewport::Tick( const FGeometry& AllottedGeometry, double InCurrentTime, float DeltaTime )
|
|
{
|
|
if (!bIsPopup)
|
|
{
|
|
// Calculate max corner of the viewport using same method as Slate
|
|
FVector2D MaxPos = AllottedGeometry.AbsolutePosition + AllottedGeometry.GetLocalSize();
|
|
// Get size by subtracting as int to avoid incorrect rounding when size and position are .5
|
|
WebBrowserWindow->SetViewportSize(MaxPos.IntPoint() - AllottedGeometry.AbsolutePosition.IntPoint());
|
|
}
|
|
}
|
|
|
|
bool FWebBrowserViewport::RequiresVsync() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FWebBrowserViewport::AllowScaling() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
FCursorReply FWebBrowserViewport::OnCursorQuery( const FGeometry& MyGeometry, const FPointerEvent& CursorEvent )
|
|
{
|
|
return WebBrowserWindow->OnCursorQuery(MyGeometry, CursorEvent);
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
// Capture mouse on left button down so that you can drag out of the viewport
|
|
FReply Reply = WebBrowserWindow->OnMouseButtonDown(MyGeometry, MouseEvent, bIsPopup);
|
|
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
|
|
{
|
|
const FWidgetPath* Path = MouseEvent.GetEventPath();
|
|
if (Path->IsValid())
|
|
{
|
|
TSharedRef<SWidget> TopWidget = Path->Widgets.Last().Widget;
|
|
return Reply.CaptureMouse(TopWidget);
|
|
}
|
|
}
|
|
return Reply;
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
// Release mouse capture when left button released
|
|
FReply Reply = WebBrowserWindow->OnMouseButtonUp(MyGeometry, MouseEvent, bIsPopup);
|
|
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
|
|
{
|
|
return Reply.ReleaseMouseCapture();
|
|
}
|
|
return Reply;
|
|
}
|
|
|
|
void FWebBrowserViewport::OnMouseEnter(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
}
|
|
|
|
void FWebBrowserViewport::OnMouseLeave(const FPointerEvent& MouseEvent)
|
|
{
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
return WebBrowserWindow->OnMouseMove(MyGeometry, MouseEvent, bIsPopup);
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
return WebBrowserWindow->OnMouseWheel(MyGeometry, MouseEvent, bIsPopup);
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent)
|
|
{
|
|
FReply Reply = WebBrowserWindow->OnMouseButtonDoubleClick(InMyGeometry, InMouseEvent, bIsPopup);
|
|
return Reply;
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent)
|
|
{
|
|
return WebBrowserWindow->OnKeyDown(InKeyEvent) ? FReply::Handled() : FReply::Unhandled();
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent)
|
|
{
|
|
return WebBrowserWindow->OnKeyUp(InKeyEvent) ? FReply::Handled() : FReply::Unhandled();
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnKeyChar( const FGeometry& MyGeometry, const FCharacterEvent& InCharacterEvent )
|
|
{
|
|
return WebBrowserWindow->OnKeyChar(InCharacterEvent) ? FReply::Handled() : FReply::Unhandled();
|
|
}
|
|
|
|
FReply FWebBrowserViewport::OnFocusReceived(const FFocusEvent& InFocusEvent)
|
|
{
|
|
WebBrowserWindow->OnFocus(true, bIsPopup);
|
|
return FReply::Handled();
|
|
}
|
|
|
|
void FWebBrowserViewport::OnFocusLost(const FFocusEvent& InFocusEvent)
|
|
{
|
|
WebBrowserWindow->OnFocus(false, bIsPopup);
|
|
}
|