Updated the SDK with the latest code from the TF and HL2 branches.
This commit is contained in:
@@ -1,441 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Creates a HTML control
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "winlite.h"
|
||||
#include "html_chrome.h"
|
||||
#include "tier1/interface.h"
|
||||
#include "reliabletimer.h"
|
||||
#include "htmlmanager.h"
|
||||
|
||||
#include "html/htmlprotobuf.h"
|
||||
#include <html/ichromehtmlwrapper.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: owner object that gets responses from the CEF thread and dispatches them
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHTMLController : public IHTMLChromeController
|
||||
{
|
||||
public:
|
||||
CHTMLController() { m_BrowserSerial = 0; m_nCefTargetFrameRate = 0; SetDefLessFunc( m_mapBrowserRequests ); SetDefLessFunc( m_mapBrowsers ); }
|
||||
~CHTMLController() {}
|
||||
|
||||
bool Init( const char *pchHTMLCacheDir, const char *pchCookiePath );
|
||||
void Shutdown();
|
||||
|
||||
void SetWebCookie( const char *pchHostname, const char *pchKey, const char *pchValue, const char *pchPath, RTime32 nExpires );
|
||||
void GetWebCookiesForURL( CUtlString *pstrValue, const char *pchURL, const char *pchName );
|
||||
void SetClientBuildID( uint64 ulBuildID );
|
||||
|
||||
bool BHasPendingMessages();
|
||||
|
||||
void CreateBrowser( IHTMLResponses *pBrowser, bool bPopupWindow, const char *pchUserAgentIdentifier );
|
||||
void RemoveBrowser( IHTMLResponses *pBrowser );
|
||||
bool RunFrame();
|
||||
|
||||
void WakeThread() { AccessHTMLWrapper().WakeThread(); }
|
||||
HTMLCommandBuffer_t *GetFreeCommandBuffer( EHTMLCommands eCmd, int iBrowser ) { return AccessHTMLWrapper().GetFreeCommandBuffer( eCmd, iBrowser ); }
|
||||
void PushCommand( HTMLCommandBuffer_t *pCmd ) { AccessHTMLWrapper().PushCommand( pCmd ); }
|
||||
|
||||
|
||||
bool GetMainThreadCommand( HTMLCommandBuffer_t **pCmd ) { return AccessHTMLWrapper().GetMainThreadCommand( pCmd ); }
|
||||
void ReleaseCommandBuffer( HTMLCommandBuffer_t *pCmd ) { AccessHTMLWrapper().ReleaseCommandBuffer( pCmd ); }
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
void Validate( CValidator &validator, const char *pchName );
|
||||
bool ChromePrepareForValidate();
|
||||
bool ChromeResumeFromValidate();
|
||||
#endif
|
||||
|
||||
void SetCefThreadTargetFrameRate( uint32 nFPS );
|
||||
|
||||
private:
|
||||
// keeps track of outstanding browser create requests
|
||||
CUtlMap< uint32, IHTMLResponses *, int > m_mapBrowserRequests;
|
||||
// the next unique identifier to use when doing a browser create
|
||||
uint32 m_BrowserSerial;
|
||||
// the map of browser handles to our html panel objects, used for cef thread command dispatching
|
||||
CUtlMap< uint32, IHTMLResponses *, int > m_mapBrowsers;
|
||||
|
||||
int m_nCefTargetFrameRate;
|
||||
};
|
||||
|
||||
|
||||
static CHTMLController s_HTMLController;
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CHTMLController, IHTMLChromeController, CHROMEHTML_CONTROLLER_INTERFACE_VERSION, s_HTMLController );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: request the cef thread to make a new browser
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::CreateBrowser( IHTMLResponses *pBrowser, bool bPopupWindow, const char *pchUserAgentIdentifier )
|
||||
{
|
||||
m_BrowserSerial++;
|
||||
m_mapBrowserRequests.Insert( m_BrowserSerial, pBrowser );
|
||||
|
||||
CHTMLProtoBufMsg<CMsgBrowserCreate> cmd( eHTMLCommands_BrowserCreate );
|
||||
cmd.Body().set_request_id( m_BrowserSerial );
|
||||
cmd.Body().set_popup( bPopupWindow );
|
||||
cmd.Body().set_useragent( pchUserAgentIdentifier );
|
||||
HTMLCommandBuffer_t *pBuf = AccessHTMLWrapper().GetFreeCommandBuffer( eHTMLCommands_BrowserCreate, -1 );
|
||||
cmd.SerializeCrossProc( &pBuf->m_Buffer );
|
||||
AccessHTMLWrapper().PushCommand( pBuf );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: delete a browser we have
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::RemoveBrowser( IHTMLResponses *pBrowser )
|
||||
{
|
||||
|
||||
// pull ourselves from the browser handle list as we are doing away
|
||||
FOR_EACH_MAP_FAST( m_mapBrowsers, i)
|
||||
{
|
||||
if ( m_mapBrowsers[i] == pBrowser )
|
||||
{
|
||||
// tell the cef thread this browser is going away
|
||||
CHTMLProtoBufMsg<CMsgBrowserRemove> cmd( eHTMLCommands_BrowserRemove );
|
||||
cmd.Body().set_browser_handle( pBrowser->BrowserGetIndex() );
|
||||
HTMLCommandBuffer_t *pBuf = AccessHTMLWrapper().GetFreeCommandBuffer( eHTMLCommands_BrowserRemove, pBrowser->BrowserGetIndex() );
|
||||
cmd.SerializeCrossProc( &pBuf->m_Buffer );
|
||||
AccessHTMLWrapper().PushCommand( pBuf );
|
||||
|
||||
// now kill it
|
||||
m_mapBrowsers.RemoveAt( i );
|
||||
}
|
||||
}
|
||||
|
||||
// also remove us from pending list if in it
|
||||
FOR_EACH_MAP_FAST( m_mapBrowserRequests, i)
|
||||
{
|
||||
if ( m_mapBrowserRequests[i] == pBrowser )
|
||||
m_mapBrowserRequests.RemoveAt( i );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: turn on the cef engine
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHTMLController::Init( const char *pchHTMLCacheDir, const char *pchCookiePath )
|
||||
{
|
||||
#if !defined(WIN64) && !defined(STATIC_TIER0)
|
||||
ChromeInit( pchHTMLCacheDir, pchCookiePath );
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: shutdown chrome
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::Shutdown()
|
||||
{
|
||||
#if !defined(WIN64) && !defined(STATIC_TIER0)
|
||||
ChromeShutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
// helper macro to dispatch messages from the cef thread
|
||||
#define HTML_MSG_FUNC( eHTMLCommand, bodyType, commandFunc ) \
|
||||
case eHTMLCommand: \
|
||||
{ \
|
||||
CHTMLProtoBufMsg< bodyType > cmd( pCmd->m_eCmd ); \
|
||||
if ( !cmd.BDeserializeCrossProc( &pCmd->m_Buffer ) ) \
|
||||
{ \
|
||||
bError = true; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
int idx = m_mapBrowsers.Find( cmd.BodyConst().browser_handle() ); \
|
||||
if ( idx != m_mapBrowsers.InvalidIndex() ) \
|
||||
{ \
|
||||
if ( m_mapBrowsers[idx] ) \
|
||||
m_mapBrowsers[idx]->commandFunc( &cmd.BodyConst() ); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
break; \
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: process any ipc responses we have pending
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHTMLController::RunFrame()
|
||||
{
|
||||
VPROF_BUDGET( "CHTMLController::RunFrame", VPROF_BUDGETGROUP_TENFOOT );
|
||||
HTMLCommandBuffer_t *pCmd;
|
||||
bool bError = false;
|
||||
bool bDidwork = false;
|
||||
|
||||
// Paint messages are dispatched last to avoid doing excessive work on
|
||||
// the main thread when two paint messages have stacked up in the queue.
|
||||
// This could be greatly optimized by doing atomic buffer swaps instead
|
||||
// of pushing the paint updates through a queue, but this helps for now.
|
||||
// -henryg
|
||||
CUtlVector< HTMLCommandBuffer_t * > vecDeferredPaint;
|
||||
|
||||
while( GetMainThreadCommand( &pCmd ) )
|
||||
{
|
||||
bool bRelease = true;
|
||||
bDidwork = true;
|
||||
//Msg( "Got response %d\n", pCmd->m_eCmd );
|
||||
switch( pCmd->m_eCmd )
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case eHTMLCommands_BrowserCreateResponse:
|
||||
{
|
||||
CHTMLProtoBufMsg< CMsgBrowserCreateResponse > cmd( pCmd->m_eCmd );
|
||||
if ( !cmd.BDeserializeCrossProc( &pCmd->m_Buffer ) )
|
||||
{
|
||||
bError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int idx = m_mapBrowserRequests.Find( cmd.BodyConst().request_id() );
|
||||
if ( idx != m_mapBrowserRequests.InvalidIndex() )
|
||||
{
|
||||
m_mapBrowsers.Insert( cmd.BodyConst().browser_handle(), m_mapBrowserRequests[idx] );
|
||||
m_mapBrowserRequests[idx]->BrowserSetIndex( cmd.BodyConst().browser_handle() );
|
||||
m_mapBrowserRequests.RemoveAt( idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eHTMLCommands_NeedsPaint:
|
||||
{
|
||||
bRelease = false;
|
||||
vecDeferredPaint.AddToTail( pCmd );
|
||||
}
|
||||
break;
|
||||
|
||||
HTML_MSG_FUNC( eHTMLCommands_BrowserReady, CMsgBrowserReady, BrowserReady );
|
||||
HTML_MSG_FUNC( eHTMLCommands_StartRequest, CMsgStartRequest, BrowserStartRequest );
|
||||
HTML_MSG_FUNC( eHTMLCommands_URLChanged, CMsgURLChanged, BrowserURLChanged );
|
||||
HTML_MSG_FUNC( eHTMLCommands_FinishedRequest, CMsgFinishedRequest, BrowserFinishedRequest );
|
||||
HTML_MSG_FUNC( eHTMLCommands_ShowPopup, CMsgShowPopup, BrowserShowPopup );
|
||||
HTML_MSG_FUNC( eHTMLCommands_HidePopup, CMsgHidePopup, BrowserHidePopup );
|
||||
HTML_MSG_FUNC( eHTMLCommands_OpenNewTab, CMsgOpenNewTab, BrowserOpenNewTab );
|
||||
HTML_MSG_FUNC( eHTMLCommands_PopupHTMLWindow, CMsgPopupHTMLWindow, BrowserPopupHTMLWindow );
|
||||
HTML_MSG_FUNC( eHTMLCommands_SetHTMLTitle, CMsgSetHTMLTitle, BrowserSetHTMLTitle );
|
||||
HTML_MSG_FUNC( eHTMLCommands_LoadingResource, CMsgLoadingResource, BrowserLoadingResource );
|
||||
HTML_MSG_FUNC( eHTMLCommands_StatusText, CMsgStatusText, BrowserStatusText );
|
||||
HTML_MSG_FUNC( eHTMLCommands_SetCursor, CMsgSetCursor, BrowserSetCursor );
|
||||
HTML_MSG_FUNC( eHTMLCommands_FileLoadDialog, CMsgFileLoadDialog, BrowserFileLoadDialog );
|
||||
HTML_MSG_FUNC( eHTMLCommands_ShowToolTip, CMsgShowToolTip, BrowserShowToolTip );
|
||||
HTML_MSG_FUNC( eHTMLCommands_UpdateToolTip, CMsgUpdateToolTip, BrowserUpdateToolTip );
|
||||
HTML_MSG_FUNC( eHTMLCommands_HideToolTip, CMsgHideToolTip, BrowserHideToolTip );
|
||||
HTML_MSG_FUNC( eHTMLCommands_SearchResults, CMsgSearchResults, BrowserSearchResults );
|
||||
HTML_MSG_FUNC( eHTMLCommands_Close, CMsgClose, BrowserClose );
|
||||
HTML_MSG_FUNC( eHTMLCommands_GetZoomResponse, CMsgGetZoomResponse, BrowserGetZoomResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_HorizontalScrollBarSizeResponse, CMsgHorizontalScrollBarSizeResponse, BrowserHorizontalScrollBarSizeResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_VerticalScrollBarSizeResponse, CMsgVerticalScrollBarSizeResponse, BrowserVerticalScrollBarSizeResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_LinkAtPositionResponse, CMsgLinkAtPositionResponse, BrowserLinkAtPositionResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_ZoomToElementAtPositionResponse, CMsgZoomToElementAtPositionResponse, BrowserZoomToElementAtPositionResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_JSAlert, CMsgJSAlert, BrowserJSAlert );
|
||||
HTML_MSG_FUNC( eHTMLCommands_JSConfirm, CMsgJSConfirm, BrowserJSConfirm );
|
||||
HTML_MSG_FUNC( eHTMLCommands_OpenSteamURL, CMsgOpenSteamURL, BrowserOpenSteamURL );
|
||||
HTML_MSG_FUNC( eHTMLCommands_CanGoBackandForward, CMsgCanGoBackAndForward, BrowserCanGoBackandForward );
|
||||
HTML_MSG_FUNC( eHTMLCommands_SizePopup, CMsgSizePopup, BrowserSizePopup );
|
||||
HTML_MSG_FUNC( eHTMLCommands_ScaleToValueResponse, CMsgScalePageToValueResponse, BrowserScalePageToValueResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_RequestFullScreen, CMsgRequestFullScreen, BrowserRequestFullScreen );
|
||||
HTML_MSG_FUNC( eHTMLCommands_ExitFullScreen, CMsgExitFullScreen, BrowserExitFullScreen );
|
||||
HTML_MSG_FUNC( eHTMLCommands_GetCookiesForURLResponse, CMsgGetCookiesForURLResponse, BrowserGetCookiesForURLResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_NodeGotFocus, CMsgNodeHasFocus, BrowserNodeGotFocus );
|
||||
HTML_MSG_FUNC( eHTMLCommands_SavePageToJPEGResponse, CMsgSavePageToJPEGResponse, BrowserSavePageToJPEGResponse );
|
||||
HTML_MSG_FUNC( eHTMLCommands_GetFocusedNodeValueResponse, CMsgFocusedNodeTextResponse, BrowserFocusedNodeValueResponse );
|
||||
}
|
||||
if ( bError )
|
||||
{
|
||||
Warning( "Failed to parse command %d", pCmd->m_eCmd );
|
||||
Assert( !"Bad Command" );
|
||||
}
|
||||
if ( bRelease )
|
||||
{
|
||||
ReleaseCommandBuffer( pCmd );
|
||||
}
|
||||
}
|
||||
|
||||
// Collapse deferred paints by browser ID and process them; the latest texture always
|
||||
// has fully updated bits, we simply union its dirty rect with the skipped updates.
|
||||
// Note: browser resizes always include a full dirty rect, we don't have to check here.
|
||||
while ( vecDeferredPaint.Count() )
|
||||
{
|
||||
// Pull the last paint off the queue
|
||||
pCmd = vecDeferredPaint[ vecDeferredPaint.Count() - 1 ];
|
||||
int iBrowser = pCmd->m_iBrowser;
|
||||
CHTMLProtoBufMsg<CMsgNeedsPaint> cmd( eHTMLCommands_NeedsPaint );
|
||||
DbgVerify( cmd.BDeserializeCrossProc( &pCmd->m_Buffer ) );
|
||||
ReleaseCommandBuffer( pCmd );
|
||||
vecDeferredPaint.Remove( vecDeferredPaint.Count() - 1 );
|
||||
|
||||
|
||||
CMsgNeedsPaint &body = cmd.Body();
|
||||
CChromeUpdateRegion region;
|
||||
if ( body.updatewide() && body.updatetall() )
|
||||
{
|
||||
region.MarkDirtyRect( body.updatex(), body.updatey(), body.updatex() + body.updatewide(), body.updatey() + body.updatetall() );
|
||||
}
|
||||
else
|
||||
{
|
||||
region.MarkAllDirty();
|
||||
}
|
||||
|
||||
// Remove earlier paints for the same browser from the queue
|
||||
for ( int i = vecDeferredPaint.Count() - 1; i >= 0; --i )
|
||||
{
|
||||
if ( vecDeferredPaint[i]->m_iBrowser == iBrowser )
|
||||
{
|
||||
// Decode
|
||||
CHTMLProtoBufMsg<CMsgNeedsPaint> cmdMerge( eHTMLCommands_NeedsPaint );
|
||||
DbgVerify( cmdMerge.BDeserializeCrossProc( &vecDeferredPaint[i]->m_Buffer ) );
|
||||
CMsgNeedsPaint &bodyMerge = cmdMerge.Body();
|
||||
|
||||
if ( body.browser_handle() == bodyMerge.browser_handle() )
|
||||
{
|
||||
ReleaseCommandBuffer( vecDeferredPaint[i] );
|
||||
vecDeferredPaint.Remove( i );
|
||||
|
||||
// Merge update region
|
||||
if ( bodyMerge.updatewide() && bodyMerge.updatetall() )
|
||||
{
|
||||
region.MarkDirtyRect( bodyMerge.updatex(), bodyMerge.updatey(), bodyMerge.updatex() + bodyMerge.updatewide(), bodyMerge.updatey() + bodyMerge.updatetall() );
|
||||
}
|
||||
else
|
||||
{
|
||||
region.MarkAllDirty();
|
||||
}
|
||||
|
||||
// Send response to the skipped paint update to free up the texture slot
|
||||
pCmd = GetFreeCommandBuffer( eHTMLCommands_NeedsPaintResponse, bodyMerge.browser_handle() );
|
||||
CHTMLProtoBufMsg<CMsgNeedsPaintResponse> cmdResponse( eHTMLCommands_NeedsPaintResponse );
|
||||
cmdResponse.Body().set_browser_handle( bodyMerge.browser_handle() );
|
||||
cmdResponse.Body().set_textureid( bodyMerge.textureid() );
|
||||
cmdResponse.SerializeCrossProc( &pCmd->m_Buffer );
|
||||
PushCommand( pCmd );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch the merged update
|
||||
int idxBrowser = m_mapBrowsers.Find( body.browser_handle() );
|
||||
if ( idxBrowser != m_mapBrowsers.InvalidIndex() )
|
||||
{
|
||||
if ( m_mapBrowsers[idxBrowser] )
|
||||
{
|
||||
int updateWide = region.GetUpdateWide( body.wide() );
|
||||
int updateTall = region.GetUpdateTall( body.tall() );
|
||||
if ( updateWide != body.wide() || updateTall != body.tall() )
|
||||
{
|
||||
body.set_updatex( region.GetUpdateX( body.wide() ) );
|
||||
body.set_updatey( region.GetUpdateY( body.tall() ) );
|
||||
body.set_updatewide( updateWide );
|
||||
body.set_updatetall( updateTall );
|
||||
}
|
||||
else
|
||||
{
|
||||
body.clear_updatex();
|
||||
body.clear_updatey();
|
||||
body.clear_updatewide();
|
||||
body.clear_updatetall();
|
||||
}
|
||||
m_mapBrowsers[idxBrowser]->BrowserNeedsPaint( &body );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bDidwork;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: set a cef cookie
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::SetWebCookie( const char *pchHostname, const char *pchKey, const char *pchValue, const char *pchPath, RTime32 nExpires )
|
||||
{
|
||||
#if !defined(WIN64) && !defined(STATIC_TIER0)
|
||||
ChromeSetWebCookie( pchHostname, pchKey, pchValue, pchPath, nExpires );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: set the buildid to report
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::SetClientBuildID( uint64 ulBuildID )
|
||||
{
|
||||
#if !defined(WIN64) && !defined(STATIC_TIER0)
|
||||
ChromeSetClientBuildID( ulBuildID );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: get the cef cookies for a url
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::GetWebCookiesForURL( CUtlString *pstrValue, const char *pchURL, const char *pchName )
|
||||
{
|
||||
#if !defined(WIN64) && !defined(STATIC_TIER0)
|
||||
ChromeGetWebCookiesForURL( pstrValue, pchURL, pchName );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: true if any pending html message in the queue
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CHTMLController::BHasPendingMessages()
|
||||
{
|
||||
return AccessHTMLWrapper().BHasPendingMessages();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: tell the cef thread the frame rate to use if it changes
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::SetCefThreadTargetFrameRate( uint32 nFPS )
|
||||
{
|
||||
if ( nFPS != m_nCefTargetFrameRate )
|
||||
{
|
||||
m_nCefTargetFrameRate = nFPS;
|
||||
CHTMLProtoBufMsg<CMsgSetTargetFrameRate> cmd( eHTMLCommands_SetTargetFrameRate );
|
||||
cmd.Body().set_ntargetframerate( nFPS );
|
||||
HTMLCommandBuffer_t *pBuf = AccessHTMLWrapper().GetFreeCommandBuffer( eHTMLCommands_SetTargetFrameRate, -1 );
|
||||
cmd.SerializeCrossProc( &pBuf->m_Buffer );
|
||||
AccessHTMLWrapper().PushCommand( pBuf );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: validate mem
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHTMLController::Validate( CValidator &validator, const char *pchName )
|
||||
{
|
||||
ChromeValidate( validator, "ChromeValidate" );
|
||||
|
||||
validator.Push( "CHTMLController::ValidateStatics", NULL, pchName );
|
||||
ValidateObj( m_mapBrowserRequests );
|
||||
ValidateObj( m_mapBrowsers );
|
||||
validator.Pop();
|
||||
}
|
||||
|
||||
bool CHTMLController::ChromeResumeFromValidate()
|
||||
{
|
||||
return ::ChromeResumeFromValidate();
|
||||
}
|
||||
|
||||
bool CHTMLController::ChromePrepareForValidate()
|
||||
{
|
||||
return ::ChromePrepareForValidate();
|
||||
}
|
||||
#endif // DBGFLAG_VALIDATE
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,637 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef HTML_CHROME_H
|
||||
#define HTML_CHROME_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "cef/include/cef_render_handler.h"
|
||||
#include "cef/include/cef_client.h"
|
||||
#include "cef/include/cef_app.h"
|
||||
#include "cef/include/cef_browser.h"
|
||||
#include "cef/include/cef_command_line.h"
|
||||
#include "cef/include/cef_frame.h"
|
||||
#include "cef/include/cef_runnable.h"
|
||||
#include "cef/include/cef_web_urlrequest.h"
|
||||
#include "cef/include/cef_request_handler.h"
|
||||
#include "cef/include/cef_load_handler.h"
|
||||
#include "cef/include/cef_display_handler.h"
|
||||
#include "cef/include/cef_life_span_handler.h"
|
||||
#include "cef/include/cef_render_handler.h"
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier0/vprof.h"
|
||||
#include "tier1/utlarray.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "fileio.h"
|
||||
//#include "constants.h"
|
||||
#include "tier0/validator.h"
|
||||
#include "tier1/utlmap.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier0/tslist.h"
|
||||
#include "html/ihtmlchrome.h"
|
||||
#include "html/htmlprotobuf.h"
|
||||
// These must be undefed so that the MacOS build will work -- their STL
|
||||
// fails if min and max are defined. I'm undefing them in all builds to
|
||||
// avoid having a Windows dependency on min/max creep in.
|
||||
#undef min
|
||||
#undef max
|
||||
#include "htmlmessages.pb.h"
|
||||
|
||||
class CClientHandler;
|
||||
class CChromePainter;
|
||||
class ICookieCallback;
|
||||
|
||||
bool ChromeSetWebCookie( const char *pchHostname, const char *pchName, const char *pchValue, const char *pchPath, RTime32 nExpires );
|
||||
bool ChromeGetWebCookiesForURL( CUtlString *pstrValue, const char *pchURL, const char *pchName );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: track dirty rects, shuttle bits between renderer and main thread
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChromeUpdateRegion
|
||||
{
|
||||
public:
|
||||
CChromeUpdateRegion() { MarkAllClean(); }
|
||||
int GetUpdateX( int clampWide ) const { return clamp( m_nUpdateX0, 0, clampWide ); }
|
||||
int GetUpdateY( int clampTall ) const { return clamp( m_nUpdateY0, 0, clampTall ); }
|
||||
int GetUpdateWide( int clampWide ) const { return clamp( m_nUpdateX1, 0, clampWide ) - GetUpdateX( clampWide ); }
|
||||
int GetUpdateTall( int clampTall ) const { return clamp( m_nUpdateY1, 0, clampTall ) - GetUpdateY( clampTall ); }
|
||||
|
||||
void MarkAllClean() { m_nUpdateX0 = m_nUpdateY0 = INT_MAX; m_nUpdateX1 = m_nUpdateY1 = 0; }
|
||||
void MarkAllDirty() { m_nUpdateX0 = m_nUpdateY0 = 0; m_nUpdateX1 = m_nUpdateY1 = INT_MAX; }
|
||||
void MarkDirtyRect( int x0, int y0, int x1, int y1 )
|
||||
{
|
||||
if ( x0 >= x1 || y0 >= y1 ) return;
|
||||
if ( m_nUpdateX0 > x0 ) m_nUpdateX0 = x0;
|
||||
if ( m_nUpdateY0 > y0 ) m_nUpdateY0 = y0;
|
||||
if ( m_nUpdateX1 < x1 ) m_nUpdateX1 = x1;
|
||||
if ( m_nUpdateY1 < y1 ) m_nUpdateY1 = y1;
|
||||
}
|
||||
void MarkDirtyRect( const CChromeUpdateRegion& other )
|
||||
{
|
||||
MarkDirtyRect( other.m_nUpdateX0, other.m_nUpdateY0, other.m_nUpdateX1, other.m_nUpdateY1 );
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_nUpdateX0;
|
||||
int m_nUpdateY0;
|
||||
int m_nUpdateX1;
|
||||
int m_nUpdateY1;
|
||||
};
|
||||
|
||||
class CChromeRenderBuffer : public CChromeUpdateRegion
|
||||
{
|
||||
public:
|
||||
CChromeRenderBuffer() { m_nWide = m_nTall = 0; }
|
||||
void SetSize( int wide, int tall )
|
||||
{
|
||||
if ( wide != m_nWide || tall != m_nTall )
|
||||
{
|
||||
m_nWide = wide;
|
||||
m_nTall = tall;
|
||||
MarkAllDirty();
|
||||
m_Texture.EnsureCapacity( wide * tall * 4 );
|
||||
}
|
||||
}
|
||||
int GetWide() const { return m_nWide; }
|
||||
int GetTall() const { return m_nTall; }
|
||||
byte *GetPixels() { return m_Texture.Base(); }
|
||||
|
||||
bool BUpdatePixels( byte *pOther, int wide, int tall )
|
||||
{
|
||||
SetSize( wide, tall );
|
||||
int x0 = clamp( m_nUpdateX0, 0, wide );
|
||||
int y0 = clamp( m_nUpdateY0, 0, tall );
|
||||
int x1 = clamp( m_nUpdateX1, 0, wide );
|
||||
int y1 = clamp( m_nUpdateY1, 0, tall );
|
||||
if ( x0 >= x1 || y0 >= y1 )
|
||||
return false;
|
||||
|
||||
if ( x0 == 0 && x1 == wide )
|
||||
{
|
||||
byte *pDst = GetPixels() + y0*wide*4;
|
||||
byte *pSrc = pOther + y0*wide*4;
|
||||
Q_memcpy( pDst, pSrc, wide * ( y1 - y0 ) * 4 );
|
||||
}
|
||||
else
|
||||
{
|
||||
byte *pDst = GetPixels() + y0*wide*4 + x0*4;
|
||||
byte *pSrc = pOther + y0*wide*4 + x0*4;
|
||||
int nCopyBytesPerRow = (x1 - x0)*4;
|
||||
for ( int rows = y1 - y0; rows > 0; --rows )
|
||||
{
|
||||
Q_memcpy( pDst, pSrc, nCopyBytesPerRow );
|
||||
pSrc += wide * 4;
|
||||
pDst += wide * 4;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
virtual void Validate( CValidator &validator, const char *pchName )
|
||||
{
|
||||
VALIDATE_SCOPE();
|
||||
ValidateObj( m_Texture );
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
int m_nWide; // dimensions of the buffer
|
||||
int m_nTall;
|
||||
CUtlVector<byte> m_Texture; // rgba data
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: interface Chrome uses to send up paint messages
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChromePainter : public CefRenderHandler
|
||||
{
|
||||
public:
|
||||
CChromePainter( CClientHandler *pParent );
|
||||
~CChromePainter();
|
||||
|
||||
virtual bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE { return false; }
|
||||
virtual bool GetScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE { return false; }
|
||||
virtual bool GetScreenPoint(CefRefPtr<CefBrowser> browser, int viewX, int viewY, int& screenX, int& screenY) OVERRIDE { return false; }
|
||||
|
||||
virtual void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) OVERRIDE;
|
||||
virtual void OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect) OVERRIDE;
|
||||
|
||||
virtual void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects, const void* buffer) OVERRIDE;
|
||||
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser, CefCursorHandle cursor) OVERRIDE {}
|
||||
virtual bool OnSetCursor( CefRefPtr<CefBrowser> browser, const CursorType type, const void *pchIconData, int iWide, int iTall, int xHotSpot, int yHotSpot ) OVERRIDE;
|
||||
virtual bool OnFileOpenDialog( CefRefPtr<CefBrowser> browser, bool bMultiSelect, const CefString &default_title, const CefString &default_file, CefWebFileChooserCallback *pCallback ) OVERRIDE;
|
||||
virtual bool OnEnterFullScreen( CefRefPtr<CefBrowser> browser ) OVERRIDE;
|
||||
virtual bool OnExitFullScreen( CefRefPtr<CefBrowser> browser ) OVERRIDE;
|
||||
|
||||
bool BUpdated();
|
||||
void SetUpdated( bool state );
|
||||
|
||||
int GetPopupTall() const { return m_nPopupTall; }
|
||||
int GetPopupWide() const { return m_nPopupWide; }
|
||||
int GetPopupX() const { return m_nPopupX; }
|
||||
int GetPopupY() const { return m_nPopupY; }
|
||||
const byte *PPopupTextureData()
|
||||
{
|
||||
return m_PopupTexture.Base();
|
||||
}
|
||||
|
||||
uint32 FlipTexture();
|
||||
void SetTextureUploaded( uint32 id );
|
||||
bool BPaintBufferAvailable();
|
||||
|
||||
byte *PComposedTextureData( uint32 iTexture );
|
||||
int GetTall() const { return m_MainTexture.GetTall(); }
|
||||
int GetWide() const { return m_MainTexture.GetWide(); }
|
||||
int GetUpdateX() const { return m_UpdateRect.GetUpdateX( GetWide() ); }
|
||||
int GetUpdateY() const { return m_UpdateRect.GetUpdateY( GetTall() ); }
|
||||
int GetUpdateWide() const { return m_UpdateRect.GetUpdateWide( GetWide() ); }
|
||||
int GetUpdateTall() const { return m_UpdateRect.GetUpdateTall( GetTall() ); }
|
||||
void ClearUpdateRect() { m_UpdateRect.MarkAllClean(); }
|
||||
|
||||
// XXX not shuttled safely between threads, should use real buffering
|
||||
const byte *PPopupTextureDataCached();
|
||||
|
||||
bool BPopupVisible() const { return m_bPopupVisible; }
|
||||
// WebKit will show popups before they have been given a size and painted and we may do
|
||||
// a drawing pass during that time, so we want to make sure to only do something
|
||||
// with the popup when it has an actual size and content.
|
||||
bool BPopupVisibleAndPainted() const
|
||||
{
|
||||
return m_bPopupVisible &&
|
||||
m_nPopupWide != 0 &&
|
||||
m_nPopupTall != 0 &&
|
||||
m_PopupTexture.Count() >= m_nPopupWide * m_nPopupTall * 4;
|
||||
}
|
||||
void PopupRect( int &x, int &y, int &wide, int &tall ) const { x = m_nPopupX; y = m_nPopupY; wide = m_nPopupWide; tall = m_nPopupTall; }
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
virtual void Validate( CValidator &validator, const char *pchName )
|
||||
{
|
||||
VALIDATE_SCOPE();
|
||||
for ( int i = 0; i < Q_ARRAYSIZE(m_Texture); i++ )
|
||||
ValidateObj( m_Texture[i] );
|
||||
|
||||
ValidateObj( m_PopupTextureCache );
|
||||
ValidateObj( m_PopupTexture );
|
||||
ValidateObj( m_MainTexture );
|
||||
}
|
||||
#endif
|
||||
IMPLEMENT_REFCOUNTING(CChromePainter);
|
||||
|
||||
private:
|
||||
uint32 m_iNextTexture;
|
||||
uint32 m_iTexturesInFlightBits;
|
||||
int m_nPopupWide;
|
||||
int m_nPopupTall;
|
||||
CChromeRenderBuffer m_MainTexture;
|
||||
CChromeRenderBuffer m_Texture[2]; // buffering -- XXX should use atomic swap, not push multiple buffers to command buffer
|
||||
CChromeUpdateRegion m_UpdateRect;
|
||||
CUtlVector<byte> m_PopupTextureCache;
|
||||
CUtlVector<byte> m_PopupTexture;
|
||||
bool m_bUpdated;
|
||||
CClientHandler *m_pParent;
|
||||
bool m_bPopupVisible;
|
||||
int m_nPopupX, m_nPopupY;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: CEF callback object
|
||||
//-----------------------------------------------------------------------------
|
||||
class CClientHandler : public CefClient,
|
||||
public CefLifeSpanHandler,
|
||||
public CefLoadHandler,
|
||||
public CefRequestHandler,
|
||||
public CefDisplayHandler,
|
||||
|
||||
public CefJSDialogHandler,
|
||||
public CefFindHandler,
|
||||
public CefMenuHandler,
|
||||
public CefFocusHandler,
|
||||
public CefPermissionHandler
|
||||
{
|
||||
public:
|
||||
CClientHandler( int iBrowser, const char *pchUserAgent, uint16 nSerial );
|
||||
~CClientHandler();
|
||||
|
||||
// CefClient methods
|
||||
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE {
|
||||
return &m_Painter;
|
||||
}
|
||||
|
||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual CefRefPtr<CefMenuHandler> GetMenuHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefPermissionHandler> GetPermissionHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual CefRefPtr<CefFindHandler> GetFindHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
// CefLifeSpanHandler methods
|
||||
|
||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, const CefString& url, CefRefPtr<CefClient>& client, CefBrowserSettings& settings) OVERRIDE;
|
||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual bool DoClose(CefRefPtr<CefBrowser> browser) { return false; }
|
||||
virtual bool OnNewTab(CefRefPtr<CefBrowser> parentBrowser, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, const CefString& url, bool bForeground, CefRefPtr<CefClient>& client, CefBrowserSettings& settings );
|
||||
|
||||
// CefLoadHandler methods
|
||||
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, bool bIsNewNavigation ) OVERRIDE;
|
||||
|
||||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode, CefRefPtr<CefRequest> request ) OVERRIDE;
|
||||
virtual bool OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& failedUrl, CefString& errorText);
|
||||
|
||||
// CefRequestHandler methods
|
||||
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, NavType navType, bool isRedirect, bool isNewTabRequest );
|
||||
virtual bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefRequest> request, CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream, CefRefPtr<CefResponse> response, int loadFlags);
|
||||
|
||||
// CefDisplayHandler methods
|
||||
virtual void OnNavStateChange(CefRefPtr<CefBrowser> browser, bool canGoBack, bool canGoForward) OVERRIDE {}
|
||||
virtual void OnAddressChange(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& url) OVERRIDE { }
|
||||
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title) OVERRIDE;
|
||||
|
||||
virtual bool OnTooltip(CefRefPtr<CefBrowser> browser, CefString& text);
|
||||
virtual void OnStatusMessage(CefRefPtr<CefBrowser> browser, const CefString& value, StatusType type);
|
||||
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser, const CefString& message, const CefString& source, int line);
|
||||
|
||||
virtual void OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) {}
|
||||
virtual bool OnSetFocus(CefRefPtr<CefBrowser> browser, FocusSource source) { return true; }
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node);
|
||||
|
||||
virtual bool OnBeforeMenu(CefRefPtr<CefBrowser> browser, const CefMenuInfo& menuInfo) { return true; }
|
||||
virtual void GetMenuLabel(CefRefPtr<CefBrowser> browser, MenuId menuId, CefString& label) {}
|
||||
virtual bool OnMenuAction(CefRefPtr<CefBrowser> browser, MenuId menuId) { return true; }
|
||||
virtual bool OnBeforeScriptExtensionLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& extensionName) { return false; }
|
||||
|
||||
virtual void OnFindResult(CefRefPtr<CefBrowser> browser, int identifier, int count, const CefRect& selectionRect, int activeMatchOrdinal, bool finalUpdate);
|
||||
virtual bool OnJSAlert(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& message);
|
||||
virtual bool OnJSConfirm(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& message, bool& retval);
|
||||
virtual bool OnJSPrompt(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& message, const CefString& defaultValue, bool& retval, CefString& result);
|
||||
|
||||
void FileOpenDialogResult( const char *pchFileName );
|
||||
|
||||
|
||||
// paint helpers
|
||||
void Paint();
|
||||
bool BNeedsPaint();
|
||||
|
||||
int GetTextureTall() const { return m_Painter.GetTall(); }
|
||||
int GetTextureWide() const { return m_Painter.GetWide(); }
|
||||
int GetUpdateX() const { return m_Painter.GetUpdateX(); }
|
||||
int GetUpdateY() const { return m_Painter.GetUpdateY(); }
|
||||
int GetUpdateWide() const { return m_Painter.GetUpdateWide(); }
|
||||
int GetUpdateTall() const { return m_Painter.GetUpdateTall(); }
|
||||
|
||||
const byte *PPopupTextureDataCached() { return m_Painter.PPopupTextureDataCached(); }
|
||||
bool BPopupVisible() const { return m_Painter.BPopupVisible(); }
|
||||
bool BPopupVisibleAndPainted() const { return m_Painter.BPopupVisibleAndPainted(); }
|
||||
void PopupRect( int &x, int &y, int &wide, int &tall ) const { m_Painter.PopupRect( x, y, wide, tall ); }
|
||||
|
||||
const byte *PComposedTextureData( uint32 iTexture );
|
||||
uint32 FlipTexture() { return m_Painter.FlipTexture(); }
|
||||
void SetTextureUploaded( uint32 iTexture ) { m_Painter.SetTextureUploaded( iTexture ); }
|
||||
void ClearUpdateRect() { m_Painter.ClearUpdateRect(); }
|
||||
bool BPaintBufferReady() { return m_Painter.BPaintBufferAvailable(); }
|
||||
|
||||
// Helpers
|
||||
CefRefPtr<CefBrowser> GetBrowser();
|
||||
void CloseBrowser();
|
||||
uint32 GetPageSerial() { return m_nPageSerial; }
|
||||
void SetPendingPageSerial( uint32 nPageSerial )
|
||||
{
|
||||
m_nPendingPageSerial = nPageSerial;
|
||||
}
|
||||
|
||||
|
||||
void SetUserAgent( const char *pchAgent ) { Q_strncpy( m_szUserAgentExtras, pchAgent, sizeof(m_szUserAgentExtras) ); }
|
||||
const char *PchCurrentURL() { return m_strCurrentUrl.String(); }
|
||||
bool IsVisuallyNonEmpty();
|
||||
void SetErrorStrings( const char *pchTitle, const char *pchHeader, const char *pchCacheMiss, const char *pchBadURL, const char *pchConnectionProblem,
|
||||
const char *pchProxyProblem, const char *pchUnknown );
|
||||
void SetMouseLocation( int x, int y );
|
||||
void GetMouseLocation( int &x, int &y ) { x = m_nMouseX; y = m_nMouseY; }
|
||||
void SetMouseFocus( bool bFocus ) { m_bMouseFocus = bFocus; }
|
||||
void SetSize( int wide, int tall ) { m_nExpectedWide = wide; m_nExpectedTall = tall; }
|
||||
void GetExpectedSize( int &wide, int &tall ) { wide = m_nExpectedWide; tall =m_nExpectedTall; }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Adds a custom header to all requests
|
||||
//-----------------------------------------------------------------------------
|
||||
void AddHeader( const char *pchHeader, const char *pchValue )
|
||||
{
|
||||
m_vecHeaders.AddToTail( std::make_pair( CStrAutoEncode( pchHeader ).ToWString(), CStrAutoEncode( pchValue ).ToWString() ) );
|
||||
}
|
||||
|
||||
void RequestScreenShot( const CHTMLProtoBufMsg<CMsgSavePageToJPEG> &cmd );
|
||||
void SavePageToJPEGIfNeeded( CefRefPtr<CefBrowser> browser, const byte *pRGBA, int wide, int tall );
|
||||
bool BPendingScreenShot()
|
||||
{
|
||||
return m_Snapshot.m_flRequestTimeout > 0.0f && m_Snapshot.m_sURLSnapshot.IsValid() && m_Snapshot.m_flRequestTimeout < Plat_FloatTime();
|
||||
}
|
||||
|
||||
void SetUserAgentIdentifier( const char *pchIdent )
|
||||
{
|
||||
m_strUserAgentIdentifier = pchIdent;
|
||||
}
|
||||
|
||||
uint16 NSerial() { return m_nSerial; }
|
||||
|
||||
void RefreshCEFHoverStatesAfterScroll();
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
virtual void Validate( CValidator &validator, const char *pchName )
|
||||
{
|
||||
VALIDATE_SCOPE();
|
||||
ValidateObj( m_strCurrentUrl );
|
||||
ValidateObj( m_strPostData );
|
||||
ValidateObj( m_strLastRedirectURL );
|
||||
ValidateObj( m_vecHeaders );
|
||||
ValidateObj( m_strUserAgent );
|
||||
ValidateObj( m_Painter );
|
||||
ValidateObj( m_sErrorTitle );
|
||||
ValidateObj( m_sErrorHeader );
|
||||
ValidateObj( m_sErrorCacheMiss );
|
||||
ValidateObj( m_sErrorBadURL );
|
||||
ValidateObj( m_sErrorConnectionProblem );
|
||||
ValidateObj( m_sErrorProxyProblem );
|
||||
ValidateObj( m_sErrorUnknown );
|
||||
ValidateObj( m_strUserAgentIdentifier );
|
||||
// ValidateObj( m_vecHCursor );
|
||||
}
|
||||
#endif
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CClientHandler);
|
||||
IMPLEMENT_LOCKING(CClientHandler);
|
||||
private:
|
||||
friend class CChromePainter;
|
||||
friend class CCEFThread;
|
||||
|
||||
void SetBrowserAgent( CefRefPtr<CefBrowser> browser );
|
||||
|
||||
// The child browser window
|
||||
CefRefPtr<CefBrowser> m_Browser;
|
||||
|
||||
CefRenderHandler::CefWebFileChooserCallback *m_pOpenFileCallback;
|
||||
|
||||
uint16 m_nSerial;
|
||||
char m_szUserAgentExtras[ 256 ];
|
||||
CUtlString m_strCurrentUrl;
|
||||
CUtlString m_strPostData;
|
||||
CUtlString m_strLastRedirectURL;
|
||||
CUtlString m_strUserAgent;
|
||||
CUtlString m_strUserAgentIdentifier;
|
||||
CUtlString m_strToolTip;
|
||||
bool m_bShowingToolTip;
|
||||
bool m_bPendingPaint;
|
||||
bool m_bBrowserClosing;
|
||||
bool m_bMouseFocus;
|
||||
CChromePainter m_Painter;
|
||||
CUtlVector< std::pair< std::wstring, std::wstring > > m_vecHeaders;
|
||||
int m_iBrowser;
|
||||
int m_nExpectedWide;
|
||||
int m_nExpectedTall;
|
||||
uint32 m_nPageSerial;
|
||||
uint32 m_nPendingPageSerial;
|
||||
|
||||
CUtlString m_sErrorTitle;
|
||||
CUtlString m_sErrorHeader;
|
||||
CUtlString m_sErrorCacheMiss;
|
||||
CUtlString m_sErrorBadURL;
|
||||
CUtlString m_sErrorConnectionProblem;
|
||||
CUtlString m_sErrorProxyProblem;
|
||||
CUtlString m_sErrorUnknown;
|
||||
int m_nMouseX;
|
||||
int m_nMouseY;
|
||||
int m_nMouseScrolledX;
|
||||
int m_nMouseScrolledY;
|
||||
|
||||
struct SnapshotData_t
|
||||
{
|
||||
CUtlString m_sURLSnapshot;
|
||||
CUtlString m_sFileNameSnapshot;
|
||||
int m_nWide, m_nTall;
|
||||
float m_flRequestTimeout;
|
||||
};
|
||||
|
||||
SnapshotData_t m_Snapshot;
|
||||
|
||||
// Scroll bar state is cached and compared to CEF's current values every frame;
|
||||
// any changes are passed on to the client handler as serialized update messages.
|
||||
struct CachedScrollBarState_t
|
||||
{
|
||||
int m_nX;
|
||||
int m_nY;
|
||||
int m_nWide;
|
||||
int m_nTall;
|
||||
int m_nMax;
|
||||
int m_nScroll;
|
||||
int m_bVisible; // using 'int' to avoid padding bytes so memcmp can be used
|
||||
};
|
||||
CachedScrollBarState_t m_CachedVScroll;
|
||||
CachedScrollBarState_t m_CachedHScroll;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: CEF thinking thread
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCEFThread : public CValidatableThread
|
||||
{
|
||||
public:
|
||||
CCEFThread();
|
||||
~CCEFThread();
|
||||
void SetCEFPaths( const char *pchHTMLCacheDir, const char *pchCookiePath );
|
||||
void TriggerShutdown();
|
||||
void WakeThread();
|
||||
virtual int Run();
|
||||
|
||||
bool BHasPendingMessages() { return m_tslResponseBuffers.Count() > 0; }
|
||||
|
||||
HTMLCommandBuffer_t *GetFreeCommandBuffer( EHTMLCommands eCmd, int iBrowser );
|
||||
void ReleaseCommandBuffer( HTMLCommandBuffer_t *pBuf );
|
||||
void PushCommand( HTMLCommandBuffer_t * );
|
||||
void PushResponse( HTMLCommandBuffer_t * );
|
||||
bool GetMainThreadCommand( HTMLCommandBuffer_t ** );
|
||||
HTMLCommandBuffer_t *BWaitForCommand( EHTMLCommands eCmd, int iBrowser );
|
||||
HTMLCommandBuffer_t *BWaitForResponse( EHTMLCommands eCmd, int iBrowser );
|
||||
bool GetCEFThreadCommand( HTMLCommandBuffer_t **pBuf );
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
virtual void SleepForValidate() { CValidatableThread::SleepForValidate(); m_evWaitingForCommand.Set(); WakeThread(); }
|
||||
virtual void Validate( CValidator &validator, const tchar *pchName );
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
void RunCurrentCommands();
|
||||
const char *PchWebkitUserAgent();
|
||||
void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app);
|
||||
void CleanupTempFolders();
|
||||
|
||||
void ThreadCreateBrowser( const CHTMLProtoBufMsg<CMsgBrowserCreate> &htmlCommand );
|
||||
void ThreadRemoveBrowser( const CHTMLProtoBufMsg<CMsgBrowserRemove> &htmlCommand );
|
||||
void ThreadBrowserSize( const CHTMLProtoBufMsg<CMsgBrowserSize> &htmlCommand );
|
||||
void ThreadBrowserPosition( const CHTMLProtoBufMsg<CMsgBrowserPosition> &htmlCommand );
|
||||
void ThreadBrowserPostURL( const CHTMLProtoBufMsg<CMsgPostURL> &htmlCommand );
|
||||
void ThreadBrowserStopLoad( const CHTMLProtoBufMsg<CMsgStopLoad> &htmlCommand );
|
||||
void ThreadBrowserReload( const CHTMLProtoBufMsg<CMsgReload> &htmlCommand );
|
||||
void ThreadBrowserGoForward( const CHTMLProtoBufMsg<CMsgGoForward> &htmlCommand );
|
||||
void ThreadBrowserGoBack( const CHTMLProtoBufMsg<CMsgGoBack> &htmlCommand );
|
||||
void ThreadBrowserCopy( const CHTMLProtoBufMsg<CMsgCopy> &htmlCommand );
|
||||
void ThreadBrowserPaste( const CHTMLProtoBufMsg<CMsgPaste> &htmlCommand );
|
||||
void ThreadBrowserExecuteJavascript( const CHTMLProtoBufMsg<CMsgExecuteJavaScript> &htmlCommand );
|
||||
void ThreadBrowserSetFocus( const CHTMLProtoBufMsg<CMsgSetFocus> &htmlCommand );
|
||||
void ThreadBrowserHorizontalScrollBarSize( const CHTMLProtoBufMsg<CMsgHorizontalScrollBarSize> &htmlCommand );
|
||||
void ThreadBrowserVerticalScrollBarSize( const CHTMLProtoBufMsg<CMsgVerticalScrollBarSize> &htmlCommand );
|
||||
void ThreadBrowserFind( const CHTMLProtoBufMsg<CMsgFind> &htmlCommand );
|
||||
void ThreadBrowserStopFind( const CHTMLProtoBufMsg<CMsgStopFind> &htmlCommand );
|
||||
void ThreadBrowserSetHorizontalScroll( const CHTMLProtoBufMsg<CMsgSetHorizontalScroll> &htmlCommand );
|
||||
void ThreadBrowserSetVerticalScroll( const CHTMLProtoBufMsg<CMsgSetVerticalScroll> &htmlCommand );
|
||||
void ThreadBrowserSetZoomLevel( const CHTMLProtoBufMsg<CMsgSetZoomLevel> &htmlCommand );
|
||||
void ThreadBrowserViewSource( const CHTMLProtoBufMsg<CMsgViewSource> &htmlCommand );
|
||||
void ThreadNeedsPaintResponse( const CHTMLProtoBufMsg<CMsgNeedsPaintResponse> &htmlCommand );
|
||||
void ThreadBrowserErrorStrings( const CHTMLProtoBufMsg<CMsgBrowserErrorStrings> &htmlCommand );
|
||||
void ThreadAddHeader( const CHTMLProtoBufMsg<CMsgAddHeader> &htmlCommand );
|
||||
void ThreadGetZoom( const CHTMLProtoBufMsg<CMsgGetZoom> &htmlCommand );
|
||||
void ThreadHidePopup( const CHTMLProtoBufMsg<CMsgHidePopup> &htmlCommand );
|
||||
void ThreadGetCookiesForURL( const CHTMLProtoBufMsg<CMsgGetCookiesForURL> &htmlCommand );
|
||||
|
||||
void ThreadKeyDown( const CHTMLProtoBufMsg<CMsgKeyDown> &htmlCommand );
|
||||
void ThreadKeyUp( const CHTMLProtoBufMsg<CMsgKeyUp> &htmlCommand );
|
||||
void ThreadKeyTyped( const CHTMLProtoBufMsg<CMsgKeyChar> &htmlCommand );
|
||||
void ThreadMouseButtonDown( const CHTMLProtoBufMsg<CMsgMouseDown> &htmlCommand );
|
||||
void ThreadMouseButtonUp( const CHTMLProtoBufMsg<CMsgMouseUp> &htmlCommand );
|
||||
void ThreadMouseButtonDlbClick( const CHTMLProtoBufMsg<CMsgMouseDblClick> &htmlCommand );
|
||||
void ThreadMouseWheel( const CHTMLProtoBufMsg<CMsgMouseWheel> &htmlCommand );
|
||||
void ThreadMouseMove( const CHTMLProtoBufMsg<CMsgMouseMove> &htmlCommand );
|
||||
void ThreadMouseLeave( const CHTMLProtoBufMsg<CMsgMouseLeave> &htmlCommand );
|
||||
void ThreadLinkAtPosition( const CHTMLProtoBufMsg<CMsgLinkAtPosition> &htmlCommand );
|
||||
void ThreadZoomToElementAtPosition( const CHTMLProtoBufMsg<CMsgZoomToElementAtPosition> &htmlCommand );
|
||||
void ThreadZoomToFocusedElement( const CHTMLProtoBufMsg<CMsgZoomToFocusedElement> &htmlCommand );
|
||||
void ThreadSavePageToJPEG( const CHTMLProtoBufMsg<CMsgSavePageToJPEG> &htmlCommand );
|
||||
void ThreadSetCookie( const CHTMLProtoBufMsg<CMsgSetCookie> &htmlCommand );
|
||||
void ThreadSetTargetFrameRate( const CHTMLProtoBufMsg<CMsgSetTargetFrameRate> &htmlCommand );
|
||||
void ThreadFullRepaint( const CHTMLProtoBufMsg<CMsgFullRepaint> &htmlCommand );
|
||||
void ThreadSetPageScale( const CHTMLProtoBufMsg<CMsgScalePageToValue> &htmlCommand );
|
||||
void ThreadExitFullScreen( const CHTMLProtoBufMsg<CMsgExitFullScreen> &htmlCommand );
|
||||
void ThreadCloseFullScreenFlashIfOpen( const CHTMLProtoBufMsg<CMsgCloseFullScreenFlashIfOpen> &htmlCommand );
|
||||
void ThreadPauseFullScreenFlashMovieIfOpen( const CHTMLProtoBufMsg<CMsgPauseFullScreenFlashMovieIfOpen> &htmlCommand );
|
||||
void ThreadGetFocusedNodeText( const CHTMLProtoBufMsg<CMsgFocusedNodeText> &htmlCommand );
|
||||
|
||||
void ThreadBrowserVerticalScrollBarSizeHelper( int iBrowser, bool bForceSendUpdate );
|
||||
void ThreadBrowserHorizontalScrollBarSizeHelper( int iBrowser, bool bForceSendUpdate );
|
||||
|
||||
bool BIsValidBrowserHandle( uint32 nHandle, int &iClient );
|
||||
void SendSizeChangeEvents();
|
||||
void CheckForFullScreenFlashControl();
|
||||
|
||||
CThreadEvent m_WakeEvent;
|
||||
CUtlString m_sHTMLCacheDir;
|
||||
CUtlString m_sCookiePath;
|
||||
bool m_bExit;
|
||||
CThreadEvent m_eventDidExit;
|
||||
|
||||
CUtlLinkedList<CClientHandler *> m_listClientHandlers;
|
||||
|
||||
CTSQueue<HTMLCommandBuffer_t*> m_tslCommandBuffers;
|
||||
CUtlVector<HTMLCommandBuffer_t*> m_vecQueueCommands;
|
||||
CTSQueue<HTMLCommandBuffer_t*> m_tslResponseBuffers;
|
||||
CUtlVector<HTMLCommandBuffer_t*> m_vecQueueResponses;
|
||||
|
||||
CTSList<HTMLCommandBuffer_t*> m_tslUnsedBuffers;
|
||||
|
||||
CThreadEvent m_evWaitingForCommand;
|
||||
CThreadEvent m_evWaitingForResponse;
|
||||
int m_nTargetFrameRate;
|
||||
uint16 m_nBrowserSerial;
|
||||
bool m_bFullScreenFlashVisible;
|
||||
#ifdef WIN32
|
||||
HWND m_flashfullscreenHWND;
|
||||
#endif
|
||||
bool m_bSawUserInputThisFrame;
|
||||
|
||||
struct SizeChange_t
|
||||
{
|
||||
int iBrowser;
|
||||
int nBeforeWidth;
|
||||
int nBeforeHeight;
|
||||
float flNewZoom;
|
||||
};
|
||||
CUtlMap< int, SizeChange_t, int > m_mapSizeChangesPending;
|
||||
};
|
||||
|
||||
CCEFThread &AccessHTMLWrapper();
|
||||
|
||||
#endif // HTML_CHROME_H
|
||||
@@ -1,16 +0,0 @@
|
||||
//=========== Copyright Valve Corporation, All rights reserved. ===============//
|
||||
//
|
||||
// Purpose:
|
||||
//=============================================================================//
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
extern "C" void *CreateAutoReleasePool()
|
||||
{
|
||||
return [[NSAutoreleasePool alloc] init];
|
||||
}
|
||||
|
||||
extern "C" void ReleaseAutoReleasePool( void *pool )
|
||||
{
|
||||
[pool release];
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef HTMLMANAGER_H
|
||||
#define HTMLMANAGER_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: helper funcs to pump chrome
|
||||
//-----------------------------------------------------------------------------
|
||||
void ChromeInit( const char *pchHTMLCacheDir, const char *pchCookiePath );
|
||||
void ChromeShutdown();
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
void ChromeValidate( CValidator &validator, const char *pchName );
|
||||
bool ChromeResumeFromValidate();
|
||||
bool ChromePrepareForValidate();
|
||||
#endif
|
||||
|
||||
bool ChromeSetWebCookie( const char *pchHostname, const char *pchName, const char *pchValue, const char *pchPath );
|
||||
void ChromeSetClientBuildID( uint64 ulBuildID );
|
||||
|
||||
enum EMouseState { UP,DOWN,MOVE,DBLCLICK };
|
||||
|
||||
#endif // HTMLMANAGER_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
#ifndef STDAFX_H
|
||||
#define STDAFX_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier0/vprof.h"
|
||||
#include "tier1/utlarray.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "fileio.h"
|
||||
//#include "constants.h"
|
||||
#include "steam/steamtypes.h"
|
||||
#include "tier0/validator.h"
|
||||
#include "tier1/utlmap.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier0/tslist.h"
|
||||
#include "html/ihtmlchrome.h"
|
||||
#include "html/htmlprotobuf.h"
|
||||
|
||||
#endif
|
||||
@@ -343,7 +343,7 @@ bool AnimationController::ParseScriptFile(char *pMem, int length)
|
||||
}
|
||||
|
||||
// walk the commands
|
||||
while (token && token[0])
|
||||
while (token[0])
|
||||
{
|
||||
// get the command type
|
||||
pMem = ParseFile(pMem, token, NULL);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,7 @@ ImagePanel::ImagePanel(Panel *parent, const char *name) : Panel(parent, name)
|
||||
m_bTileImage = false;
|
||||
m_bTileHorizontally = false;
|
||||
m_bTileVertically = false;
|
||||
m_bPositionImage = true;
|
||||
m_fScaleAmount = 0.0f;
|
||||
m_FillColor = Color(0, 0, 0, 0);
|
||||
m_DrawColor = Color(255,255,255,255);
|
||||
@@ -143,25 +144,28 @@ void ImagePanel::PaintBackground()
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
if ( m_bCenterImage )
|
||||
if ( m_bPositionImage )
|
||||
{
|
||||
int wide, tall;
|
||||
GetSize(wide, tall);
|
||||
|
||||
int imageWide, imageTall;
|
||||
m_pImage->GetSize( imageWide, imageTall );
|
||||
|
||||
if ( m_bScaleImage && m_fScaleAmount > 0.0f )
|
||||
if ( m_bCenterImage )
|
||||
{
|
||||
imageWide = static_cast<int>( static_cast<float>(imageWide) * m_fScaleAmount );
|
||||
imageTall = static_cast<int>( static_cast<float>(imageTall) * m_fScaleAmount );
|
||||
}
|
||||
int wide, tall;
|
||||
GetSize(wide, tall);
|
||||
|
||||
m_pImage->SetPos( (wide - imageWide) / 2, (tall - imageTall) / 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pImage->SetPos(0, 0);
|
||||
int imageWide, imageTall;
|
||||
m_pImage->GetSize( imageWide, imageTall );
|
||||
|
||||
if ( m_bScaleImage && m_fScaleAmount > 0.0f )
|
||||
{
|
||||
imageWide = static_cast<int>( static_cast<float>(imageWide) * m_fScaleAmount );
|
||||
imageTall = static_cast<int>( static_cast<float>(imageTall) * m_fScaleAmount );
|
||||
}
|
||||
|
||||
m_pImage->SetPos( (wide - imageWide) / 2, (tall - imageTall) / 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pImage->SetPos(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bScaleImage)
|
||||
@@ -217,7 +221,11 @@ void ImagePanel::PaintBackground()
|
||||
if ( !m_bTileVertically )
|
||||
break;
|
||||
}
|
||||
m_pImage->SetPos(0, 0);
|
||||
|
||||
if ( m_bPositionImage )
|
||||
{
|
||||
m_pImage->SetPos(0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -259,6 +267,7 @@ void ImagePanel::GetSettings(KeyValues *outResourceData)
|
||||
outResourceData->SetString("border", GetBorder()->GetName());
|
||||
}
|
||||
|
||||
outResourceData->GetInt("positionImage", m_bPositionImage );
|
||||
outResourceData->SetInt("scaleImage", m_bScaleImage);
|
||||
outResourceData->SetFloat("scaleAmount", m_fScaleAmount);
|
||||
outResourceData->SetInt("tileImage", m_bTileImage);
|
||||
@@ -278,6 +287,7 @@ void ImagePanel::ApplySettings(KeyValues *inResourceData)
|
||||
m_pszFillColorName = NULL;
|
||||
m_pszDrawColorName = NULL; // HPE addition
|
||||
|
||||
m_bPositionImage = inResourceData->GetInt("positionImage", 1);
|
||||
m_bScaleImage = inResourceData->GetInt("scaleImage", 0);
|
||||
m_fScaleAmount = inResourceData->GetFloat("scaleAmount", 0.0f);
|
||||
m_bTileImage = inResourceData->GetInt("tileImage", 0);
|
||||
|
||||
@@ -1858,6 +1858,15 @@ void Panel::InternalMousePressed(int code)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef STAGING_ONLY
|
||||
// If holding CTRL + ALT, invalidate layout. For debugging purposes
|
||||
if ( ( vgui::input()->IsKeyDown(KEY_LCONTROL) || vgui::input()->IsKeyDown(KEY_RCONTROL) )
|
||||
&& ( vgui::input()->IsKeyDown(KEY_LALT) || vgui::input()->IsKeyDown(KEY_RALT) ) )
|
||||
{
|
||||
InvalidateLayout( true, true );
|
||||
}
|
||||
#endif
|
||||
|
||||
Panel *pMouseHandler = m_hMouseEventHandler.Get();
|
||||
if ( pMouseHandler )
|
||||
{
|
||||
@@ -4117,7 +4126,230 @@ void Panel::ApplyAutoResizeSettings(KeyValues *inResourceData)
|
||||
|
||||
ConVar panel_test_title_safe( "panel_test_title_safe", "0", FCVAR_CHEAT, "Test vgui panel positioning with title safe indentation" );
|
||||
|
||||
int Panel::ComputeWide( KeyValues *inResourceData, int nParentWide, int nParentTall, bool bComputingOther )
|
||||
{
|
||||
int wide = GetWide();
|
||||
|
||||
const char *wstr = inResourceData->GetString( "wide", NULL );
|
||||
if ( wstr )
|
||||
{
|
||||
if ( wstr[0] == 'f' || wstr[0] == 'F' )
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_WIDE_FULL;
|
||||
wstr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( wstr[0] == 'o' || wstr[0] == 'O' )
|
||||
{
|
||||
wstr++;
|
||||
if ( bComputingOther )
|
||||
{
|
||||
Warning( "Wide and Tall of panel %s are set to be each other!\n", GetName() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
_buildModeFlags |= BUILDMODE_SAVE_WIDE_PROPORTIONAL_TALL;
|
||||
wide = ComputeTall( inResourceData, nParentWide, nParentTall, true );
|
||||
|
||||
if ( IsProportional() )
|
||||
{
|
||||
wide = scheme()->GetProportionalNormalizedValue( wide );
|
||||
}
|
||||
}
|
||||
else if ( wstr[0] == 'p' || wstr[0] == 'P' )
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_WIDE_PROPORTIONAL;
|
||||
wstr++;
|
||||
}
|
||||
}
|
||||
|
||||
float flWide = atof(wstr);
|
||||
if ( !(_buildModeFlags & BUILDMODE_SAVE_WIDE_PROPORTIONAL_TALL) )
|
||||
{
|
||||
wide = atoi(wstr);
|
||||
}
|
||||
|
||||
if ( _buildModeFlags & BUILDMODE_SAVE_WIDE_PROPORTIONAL_TALL )
|
||||
{
|
||||
wide = scheme()->GetProportionalScaledValueEx(GetScheme(), wide);
|
||||
wide *= flWide;
|
||||
}
|
||||
else if ( _buildModeFlags & BUILDMODE_SAVE_WIDE_PROPORTIONAL )
|
||||
{
|
||||
wide = scheme()->GetProportionalScaledValueEx(GetScheme(), wide);
|
||||
wide = nParentWide - wide;
|
||||
wide *= flWide;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( IsProportional() )
|
||||
{
|
||||
// scale the width up to our screen co-ords
|
||||
wide = scheme()->GetProportionalScaledValueEx(GetScheme(), wide);
|
||||
}
|
||||
// now correct the alignment
|
||||
if (_buildModeFlags & BUILDMODE_SAVE_WIDE_FULL)
|
||||
{
|
||||
wide = nParentWide - wide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wide;
|
||||
}
|
||||
|
||||
int Panel::ComputeTall( KeyValues *inResourceData, int nParentWide, int nParentTall, bool bComputingOther )
|
||||
{
|
||||
int tall = GetTall();
|
||||
|
||||
// allow tall to be use the "fill" option, set to the height of the parent/screen
|
||||
const char *tstr = inResourceData->GetString( "tall", NULL );
|
||||
if ( tstr )
|
||||
{
|
||||
if (tstr[0] == 'f' || tstr[0] == 'F')
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_TALL_FULL;
|
||||
tstr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( tstr[0] == 'o' || tstr[0] == 'O' )
|
||||
{
|
||||
tstr++;
|
||||
if ( bComputingOther )
|
||||
{
|
||||
Warning( "Wide and Tall of panel %s are set to be each other!\n", GetName() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
_buildModeFlags |= BUILDMODE_SAVE_TALL_PROPORTIONAL_WIDE;
|
||||
tall = ComputeWide( inResourceData, nParentWide, nParentTall, true );
|
||||
if ( IsProportional() )
|
||||
{
|
||||
tall = scheme()->GetProportionalNormalizedValue( tall );
|
||||
}
|
||||
}
|
||||
else if ( tstr[0] == 'p' || tstr[0] == 'P' )
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_TALL_PROPORTIONAL;
|
||||
tstr++;
|
||||
}
|
||||
}
|
||||
|
||||
float flTall = atof(tstr);
|
||||
if ( !( _buildModeFlags & BUILDMODE_SAVE_TALL_PROPORTIONAL_WIDE ) )
|
||||
{
|
||||
tall = atoi(tstr);
|
||||
}
|
||||
|
||||
if ( _buildModeFlags & BUILDMODE_SAVE_TALL_PROPORTIONAL_WIDE )
|
||||
{
|
||||
tall = scheme()->GetProportionalScaledValueEx(GetScheme(), tall);
|
||||
tall *= flTall;
|
||||
}
|
||||
else if ( _buildModeFlags & BUILDMODE_SAVE_TALL_PROPORTIONAL )
|
||||
{
|
||||
// scale the height up to our screen co-ords
|
||||
tall = scheme()->GetProportionalScaledValueEx(GetScheme(), tall);
|
||||
tall = nParentTall - tall;
|
||||
tall *= flTall;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( IsProportional() )
|
||||
{
|
||||
// scale the height up to our screen co-ords
|
||||
tall = scheme()->GetProportionalScaledValueEx(GetScheme(), tall);
|
||||
}
|
||||
// now correct the alignment
|
||||
if (_buildModeFlags & BUILDMODE_SAVE_TALL_FULL)
|
||||
{
|
||||
tall = nParentTall - tall;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tall;
|
||||
}
|
||||
|
||||
int Panel::ComputePos( const char *pszInput, int &nPos, const int& nSize, const int& nParentSize, const bool& bX )
|
||||
{
|
||||
const int nFlagRightAlign = bX ? BUILDMODE_SAVE_XPOS_RIGHTALIGNED : BUILDMODE_SAVE_YPOS_BOTTOMALIGNED;
|
||||
const int nFlagCenterAlign = bX ? BUILDMODE_SAVE_XPOS_CENTERALIGNED : BUILDMODE_SAVE_YPOS_CENTERALIGNED;
|
||||
const int nFlagProportionalSlef = bX ? BUILDMODE_SAVE_XPOS_PROPORTIONAL_SELF : BUILDMODE_SAVE_YPOS_PROPORTIONAL_SELF;
|
||||
const int nFlagProportionalParent = bX ? BUILDMODE_SAVE_XPOS_PROPORTIONAL_PARENT : BUILDMODE_SAVE_YPOS_PROPORTIONAL_PARENT;
|
||||
|
||||
int nFlags = 0;
|
||||
if ( pszInput )
|
||||
{
|
||||
// look for alignment flags
|
||||
if (pszInput[0] == 'r' || pszInput[0] == 'R')
|
||||
{
|
||||
nFlags |= nFlagRightAlign;
|
||||
pszInput++;
|
||||
}
|
||||
else if (pszInput[0] == 'c' || pszInput[0] == 'C')
|
||||
{
|
||||
nFlags |= nFlagCenterAlign;
|
||||
pszInput++;
|
||||
}
|
||||
|
||||
if ( pszInput[0] == 's' || pszInput[0] == 'S' )
|
||||
{
|
||||
nFlags |= nFlagProportionalSlef;
|
||||
pszInput++;
|
||||
}
|
||||
else if ( pszInput[0] == 'p' || pszInput[0] == 'P' )
|
||||
{
|
||||
nFlags |= nFlagProportionalParent;
|
||||
pszInput++;
|
||||
}
|
||||
|
||||
// get the value
|
||||
nPos = atoi( pszInput );
|
||||
float flPos = atof( pszInput );
|
||||
|
||||
float flProportion = 1.f;
|
||||
// scale the x up to our screen co-ords
|
||||
if ( IsProportional() )
|
||||
{
|
||||
int nOldPos = nPos;
|
||||
nPos = scheme()->GetProportionalScaledValueEx(GetScheme(), nPos);
|
||||
flProportion = (float)nPos / (float)nOldPos;
|
||||
}
|
||||
|
||||
int nPosDelta = 0;
|
||||
if ( nFlags & nFlagProportionalSlef )
|
||||
{
|
||||
nPosDelta = nSize * flPos;
|
||||
}
|
||||
else if ( nFlags & nFlagProportionalParent )
|
||||
{
|
||||
nPosDelta = nParentSize * flPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
nPosDelta = nPos;
|
||||
}
|
||||
|
||||
// now correct the alignment
|
||||
if ( nFlags & nFlagRightAlign )
|
||||
{
|
||||
nPos = nParentSize - nPosDelta;
|
||||
}
|
||||
else if ( nFlags & nFlagCenterAlign )
|
||||
{
|
||||
nPos = (nParentSize / 2) + nPosDelta;
|
||||
}
|
||||
else
|
||||
{
|
||||
nPos = nPosDelta;
|
||||
}
|
||||
}
|
||||
|
||||
return nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads panel details from the resource info
|
||||
@@ -4135,7 +4367,19 @@ void Panel::ApplySettings(KeyValues *inResourceData)
|
||||
InternalApplySettings( GetAnimMap(), inResourceData );
|
||||
|
||||
// clear any alignment flags
|
||||
_buildModeFlags &= ~(BUILDMODE_SAVE_XPOS_RIGHTALIGNED | BUILDMODE_SAVE_XPOS_CENTERALIGNED | BUILDMODE_SAVE_YPOS_BOTTOMALIGNED | BUILDMODE_SAVE_YPOS_CENTERALIGNED | BUILDMODE_SAVE_WIDE_FULL | BUILDMODE_SAVE_TALL_FULL | BUILDMODE_SAVE_PROPORTIONAL_TO_PARENT);
|
||||
_buildModeFlags &= ~( BUILDMODE_SAVE_XPOS_RIGHTALIGNED
|
||||
| BUILDMODE_SAVE_XPOS_CENTERALIGNED
|
||||
| BUILDMODE_SAVE_YPOS_BOTTOMALIGNED
|
||||
| BUILDMODE_SAVE_YPOS_CENTERALIGNED
|
||||
| BUILDMODE_SAVE_WIDE_FULL
|
||||
| BUILDMODE_SAVE_TALL_FULL
|
||||
| BUILDMODE_SAVE_PROPORTIONAL_TO_PARENT
|
||||
| BUILDMODE_SAVE_WIDE_PROPORTIONAL_TALL
|
||||
| BUILDMODE_SAVE_TALL_PROPORTIONAL_WIDE
|
||||
| BUILDMODE_SAVE_XPOS_PROPORTIONAL_PARENT
|
||||
| BUILDMODE_SAVE_YPOS_PROPORTIONAL_PARENT
|
||||
| BUILDMODE_SAVE_XPOS_PROPORTIONAL_SELF
|
||||
| BUILDMODE_SAVE_YPOS_PROPORTIONAL_SELF );
|
||||
|
||||
// get the position
|
||||
int alignScreenWide, alignScreenTall; // screen dimensions used for pinning in splitscreen
|
||||
@@ -4169,72 +4413,17 @@ void Panel::ApplySettings(KeyValues *inResourceData)
|
||||
}
|
||||
}
|
||||
|
||||
// size
|
||||
int wide = ComputeWide( inResourceData, alignScreenWide, alignScreenTall, false );
|
||||
int tall = ComputeTall( inResourceData, alignScreenWide, alignScreenTall, false );
|
||||
|
||||
int x, y;
|
||||
GetPos(x, y);
|
||||
const char *xstr = inResourceData->GetString( "xpos", NULL );
|
||||
const char *ystr = inResourceData->GetString( "ypos", NULL );
|
||||
|
||||
if (xstr)
|
||||
{
|
||||
// look for alignment flags
|
||||
if (xstr[0] == 'r' || xstr[0] == 'R')
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_XPOS_RIGHTALIGNED;
|
||||
xstr++;
|
||||
}
|
||||
else if (xstr[0] == 'c' || xstr[0] == 'C')
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_XPOS_CENTERALIGNED;
|
||||
xstr++;
|
||||
}
|
||||
|
||||
// get the value
|
||||
x = atoi(xstr);
|
||||
// scale the x up to our screen co-ords
|
||||
if ( IsProportional() )
|
||||
{
|
||||
x = scheme()->GetProportionalScaledValueEx(GetScheme(), x);
|
||||
}
|
||||
// now correct the alignment
|
||||
if (_buildModeFlags & BUILDMODE_SAVE_XPOS_RIGHTALIGNED)
|
||||
{
|
||||
x = alignScreenWide - x;
|
||||
}
|
||||
else if (_buildModeFlags & BUILDMODE_SAVE_XPOS_CENTERALIGNED)
|
||||
{
|
||||
x = (alignScreenWide / 2) + x;
|
||||
}
|
||||
}
|
||||
|
||||
if (ystr)
|
||||
{
|
||||
// look for alignment flags
|
||||
if (ystr[0] == 'r' || ystr[0] == 'R')
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_YPOS_BOTTOMALIGNED;
|
||||
ystr++;
|
||||
}
|
||||
else if (ystr[0] == 'c' || ystr[0] == 'C')
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_YPOS_CENTERALIGNED;
|
||||
ystr++;
|
||||
}
|
||||
y = atoi(ystr);
|
||||
if (IsProportional())
|
||||
{
|
||||
// scale the y up to our screen co-ords
|
||||
y = scheme()->GetProportionalScaledValueEx(GetScheme(), y);
|
||||
}
|
||||
// now correct the alignment
|
||||
if (_buildModeFlags & BUILDMODE_SAVE_YPOS_BOTTOMALIGNED)
|
||||
{
|
||||
y = alignScreenTall - y;
|
||||
}
|
||||
else if (_buildModeFlags & BUILDMODE_SAVE_YPOS_CENTERALIGNED)
|
||||
{
|
||||
y = (alignScreenTall / 2) + y;
|
||||
}
|
||||
}
|
||||
_buildModeFlags |= ComputePos( xstr, x, wide, alignScreenWide, true );
|
||||
_buildModeFlags |= ComputePos( ystr, y, tall, alignScreenTall, false );
|
||||
|
||||
|
||||
bool bUsesTitleSafeArea = false;
|
||||
int titleSafeWide = 0;
|
||||
@@ -4343,53 +4532,6 @@ void Panel::ApplySettings(KeyValues *inResourceData)
|
||||
SetZPos( inResourceData->GetInt( "zpos" ) );
|
||||
}
|
||||
|
||||
// size
|
||||
int wide, tall;
|
||||
GetSize( wide, tall );
|
||||
|
||||
const char *wstr = inResourceData->GetString( "wide", NULL );
|
||||
if ( wstr )
|
||||
{
|
||||
if (wstr[0] == 'f' || wstr[0] == 'F')
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_WIDE_FULL;
|
||||
wstr++;
|
||||
}
|
||||
wide = atoi(wstr);
|
||||
if ( IsProportional() )
|
||||
{
|
||||
// scale the width up to our screen co-ords
|
||||
wide = scheme()->GetProportionalScaledValueEx(GetScheme(), wide);
|
||||
}
|
||||
// now correct the alignment
|
||||
if (_buildModeFlags & BUILDMODE_SAVE_WIDE_FULL)
|
||||
{
|
||||
wide = alignScreenWide - wide;
|
||||
}
|
||||
}
|
||||
|
||||
// allow tall to be use the "fill" option, set to the height of the parent/screen
|
||||
wstr = inResourceData->GetString( "tall", NULL );
|
||||
if ( wstr )
|
||||
{
|
||||
if (wstr[0] == 'f' || wstr[0] == 'F')
|
||||
{
|
||||
_buildModeFlags |= BUILDMODE_SAVE_TALL_FULL;
|
||||
wstr++;
|
||||
}
|
||||
tall = atoi(wstr);
|
||||
if ( IsProportional() )
|
||||
{
|
||||
// scale the height up to our screen co-ords
|
||||
tall = scheme()->GetProportionalScaledValueEx(GetScheme(), tall);
|
||||
}
|
||||
// now correct the alignment
|
||||
if (_buildModeFlags & BUILDMODE_SAVE_TALL_FULL)
|
||||
{
|
||||
tall = alignScreenTall - tall;
|
||||
}
|
||||
}
|
||||
|
||||
if( bUsesTitleSafeArea )
|
||||
{
|
||||
if ( _buildModeFlags & BUILDMODE_SAVE_WIDE_FULL )
|
||||
|
||||
@@ -102,7 +102,7 @@ void PerforceFileExplorer::SetCurrentDirectory( const char *pFullPath )
|
||||
|
||||
m_CurrentDirectory = pFullPath;
|
||||
m_CurrentDirectory.StripTrailingSlash();
|
||||
Q_FixSlashes( m_CurrentDirectory.Get() );
|
||||
m_CurrentDirectory.FixSlashes();
|
||||
|
||||
PopulateFileList();
|
||||
PopulateDriveList();
|
||||
|
||||
@@ -115,7 +115,13 @@ void RadioButton::ApplySchemeSettings(IScheme *pScheme)
|
||||
SetContentAlignment(a_west);
|
||||
|
||||
// reloading the scheme wipes out lists of images
|
||||
_radioBoxImage->SetFont( pScheme->GetFont("MarlettSmall", IsProportional()) );
|
||||
HFont hFont = pScheme->GetFont("MarlettSmall", IsProportional());
|
||||
if ( hFont == INVALID_FONT )
|
||||
{
|
||||
// fallback to Marlett if MarlettSmall isn't found
|
||||
hFont = pScheme->GetFont("Marlett", IsProportional());
|
||||
}
|
||||
_radioBoxImage->SetFont( hFont );
|
||||
_radioBoxImage->ResizeImageToContent();
|
||||
SetImageAtIndex(0, _radioBoxImage, 0);
|
||||
|
||||
|
||||
@@ -748,9 +748,12 @@ void RichText::Paint()
|
||||
_currentTextClickable = m_CachedRenderState.textClickable;
|
||||
|
||||
renderState.textClickable = _currentTextClickable;
|
||||
renderState.textColor = m_FormatStream[renderState.formatStreamIndex].color;
|
||||
|
||||
if ( m_FormatStream.IsValidIndex( renderState.formatStreamIndex ) )
|
||||
renderState.textColor = m_FormatStream[renderState.formatStreamIndex].color;
|
||||
|
||||
CalculateFade( renderState );
|
||||
|
||||
|
||||
renderState.formatStreamIndex++;
|
||||
|
||||
if ( _currentTextClickable )
|
||||
|
||||
@@ -99,7 +99,6 @@ $Project "vgui_controls"
|
||||
$File "URLLabel.cpp"
|
||||
$File "WizardPanel.cpp"
|
||||
$File "WizardSubPanel.cpp"
|
||||
$File "$SRCDIR\public\html\htmlprotobuf.cpp"
|
||||
$File "$SRCDIR/vgui2/src/vgui_key_translation.cpp"
|
||||
}
|
||||
|
||||
@@ -196,21 +195,4 @@ $Project "vgui_controls"
|
||||
$File "$SRCDIR\public\vgui_controls\WizardPanel.h"
|
||||
$File "$SRCDIR\public\vgui_controls\WizardSubPanel.h"
|
||||
}
|
||||
|
||||
$Folder "Protobuf Files"
|
||||
{
|
||||
$File "$SRCDIR\vgui2\chromehtml\htmlmessages.proto"
|
||||
$DynamicFile "$GENERATED_PROTO_DIR\htmlmessages.pb.h"
|
||||
$DynamicFile "$GENERATED_PROTO_DIR\htmlmessages.pb.cc"
|
||||
{
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$Create/UsePrecompiledHeader "Not Using Precompiled Headers" [$WINDOWS]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user