15#pragma GCC diagnostic ignored "-Wunused-parameter"
16#pragma GCC diagnostic ignored "-Wshadow"
28#include "include/base/cef_build.h"
41 CefDoMessageLoopWork();
56 void Visit(
const CefString &str)
override
59 fHandle->SetContent(str.ToString());
88 auto handle = std::make_unique<RCefWebDisplayHandle>(args.
GetFullUrl());
90 handle->fCloseBrowser =
false;
92 Int_t wait_tmout = args.
IsHeadless() ?
gEnv->GetValue(
"WebGui.CefHeadlessTimeout", 30) : -1;
103 handle->WaitForContent(wait_tmout, args.
GetExtraArgs());
109 bool use_views =
true;
111 TString env_use_views =
gEnv->GetValue(
"WebGui.CefUseViews",
"");
112 if ((env_use_views ==
"yes") || (env_use_views ==
"1"))
114 else if ((env_use_views ==
"no") || (env_use_views ==
"0"))
118 CefSettings settings;
120 TString ceflog =
gEnv->GetValue(
"WebGui.CefLogSeveriry",
"fatal");
121 if (ceflog ==
"fatal")
122 settings.log_severity = LOGSEVERITY_FATAL;
123 else if (ceflog ==
"verbose")
124 settings.log_severity = LOGSEVERITY_VERBOSE;
125 else if (ceflog ==
"info")
126 settings.log_severity = LOGSEVERITY_INFO;
127 else if (ceflog ==
"warning")
128 settings.log_severity = LOGSEVERITY_WARNING;
129 else if (ceflog ==
"error")
130 settings.log_severity = LOGSEVERITY_ERROR;
131 else if (ceflog ==
"disable")
132 settings.log_severity = LOGSEVERITY_DISABLE;
134 settings.log_severity = LOGSEVERITY_FATAL;
136 bool supress_log = (settings.log_severity == LOGSEVERITY_DISABLE) ||
137 (settings.log_severity == LOGSEVERITY_FATAL);
144 CefMainArgs main_args(GetModuleHandle(
nullptr));
150 std::vector<const char *> cef_argv = { root_app->
Argv(0) };
153 cef_argv.emplace_back(
"--disable-logging");
154 cef_argv.emplace_back(
"--enable-logging=none");
155 cef_argv.emplace_back(
"--v=-1");
158 cef_argv.emplace_back(
nullptr);
160 CefMainArgs main_args(cef_argv.size() - 1, (
char **) cef_argv.data());
182 cef_string_ascii_to_utf16(cef_main.
Data(), cef_main.
Length(), &settings.browser_subprocess_path);
187 cef_string_ascii_to_utf16(path.
Data(), path.
Length(), &settings.framework_dir_path);
193 dypath.
Append(path +
"/Libraries/");
194 gSystem->Setenv(
"DYLD_LIBRARY_PATH", dypath);
199 cef_string_ascii_to_utf16(resource_dir.
Data(), resource_dir.
Length(), &settings.resources_dir_path);
201 cef_string_ascii_to_utf16(locales_dir.
Data(), locales_dir.
Length(), &settings.locales_dir_path);
206 cef_string_ascii_to_utf16(resource_dir.
Data(), resource_dir.
Length(), &settings.resources_dir_path);
208 cef_string_ascii_to_utf16(locales_dir.
Data(), locales_dir.
Length(), &settings.locales_dir_path);
211 settings.no_sandbox =
true;
215 settings.windowless_rendering_enabled =
true;
220 std::string plog =
"cef.log";
221 cef_string_ascii_to_utf16(plog.c_str(), plog.length(), &settings.log_file);
240 CefInitialize(main_args, settings,
fCefApp.get(),
nullptr);
243 handle->WaitForContent(wait_tmout, args.
GetExtraArgs());
246 Int_t interval =
gEnv->GetValue(
"WebGui.CefTimer", 10);
273 if (host) host->CloseBrowser(
true);
284 int expired = tmout_sec * 100;
285 bool did_try =
false, print_finished =
false;
287 if (!extra_args.empty() && (extra_args.find(
"--print-to-pdf=")==0))
288 pdffile = extra_args.substr(15);
290 while ((--expired > 0) &&
GetContent().empty() && !print_finished) {
292 if (
gSystem->ProcessEvents())
break;
294 CefDoMessageLoopWork();
298 if (pdffile.empty()) {
301 CefPdfPrintSettings settings;
312 CefDoMessageLoopWork();
334 GetMap().emplace(
"cef", std::make_unique<CefCreator>());
struct RCefCreatorReg newRCefCreatorReg
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
R__EXTERN TSystem * gSystem
DISALLOW_COPY_AND_ASSIGN(FrameSourceVisitor)
void Visit(const CefString &str) override
FrameSourceVisitor(RCefWebDisplayHandle *handle)
IMPLEMENT_REFCOUNTING(FrameSourceVisitor)
RCefWebDisplayHandle * fHandle
~FrameSourceVisitor() override=default
static bool PlatformResize(CefRefPtr< CefBrowser > browser, int width, int height)
static void PlatformInit()
void OnPdfPrintFinished(const CefString &, bool ok) override
~HeadlessPrintCallback() override=default
HeadlessPrintCallback(bool *flag)
IMPLEMENT_REFCOUNTING(HeadlessPrintCallback)
DISALLOW_COPY_AND_ASSIGN(HeadlessPrintCallback)
CefRefPtr< SimpleApp > fCefApp
std::unique_ptr< ROOT::RWebDisplayHandle > Display(const ROOT::RWebDisplayArgs &args) override
CefRefPtr< CefBrowser > fBrowser
associated browser
void CloseBrowser()
Closes associated browser window.
static void AddCreator()
Add CEF creator.
bool WaitForContent(int tmout_sec, const std::string &extra_args)
Process system events until browser content is available Used in headless mode for batch production l...
unsigned fValid
used to verify if instance valid or not
~RCefWebDisplayHandle() override
Destructor Closes browser window if any.
bool Resize(int, int) override
Resize browser window.
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
THttpServer * GetHttpServer() const
returns http server instance, used for window display
int GetWidth() const
returns preferable web window width
int GetY() const
set preferable web window y position
std::string GetFullUrl() const
returns window url with append options
bool IsStandalone() const
Return true if browser should runs in standalone mode.
int GetHeight() const
returns preferable web window height
bool IsHeadless() const
returns headless mode
const std::string & GetExtraArgs() const
get extra command line arguments for starting web browser command
int GetX() const
set preferable web window x position
const std::string & GetPageContent() const
returns window url
const std::string & GetContent() const
get content
static std::map< std::string, std::unique_ptr< Creator > > & GetMap()
Static holder of registered creators of web displays.
static std::unique_ptr< Creator > & FindCreator(const std::string &name, const std::string &libname="")
Search for specific browser creator If not found, try to add one.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
TCefTimer(Long_t milliSec, Bool_t mode)
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
static const TString & GetLibDir()
Get the library directory in the installation.
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
const char * Data() const
TString & Append(const char *cs)
virtual void TurnOn()
Add the timer to the system timer list.
TTimer(const TTimer &)=delete