17#include "RConfigure.h"
45using namespace std::string_literals;
61 static std::map<std::string, std::unique_ptr<RWebDisplayHandle::Creator>> sMap;
74 auto search =
m.find(
name);
75 if (search ==
m.end()) {
77 if (libname ==
"ChromeCreator") {
78 m.emplace(
name, std::make_unique<ChromeCreator>(
name ==
"edge"));
79 }
else if (libname ==
"FirefoxCreator") {
80 m.emplace(
name, std::make_unique<FirefoxCreator>());
81 }
else if (libname ==
"SafariCreator") {
82 m.emplace(
name, std::make_unique<SafariCreator>());
83 }
else if (libname ==
"BrowserCreator") {
84 m.emplace(
name, std::make_unique<BrowserCreator>(
false));
85 }
else if (!libname.empty()) {
89 search =
m.find(
name);
92 if (search !=
m.end())
93 return search->second;
95 static std::unique_ptr<RWebDisplayHandle::Creator> dummy;
118 RWebBrowserHandle(
const std::string &url,
const std::string &tmpdir,
const std::string &tmpfile,
const std::string &dump) :
133 gSystem->
Exec((
"taskkill /F /PID "s + std::to_string(
fPid) +
" >NUL 2>NUL").c_str());
134 std::string rmdir =
"rmdir /S /Q ", rmfile =
"del /F ";
138 std::string rmdir =
"rm -rf ", rmfile =
"rm -f ";
158 if (exec.find(
"$url") == std::string::npos) {
161 fExec = exec +
" $url";
163 fExec = exec +
" $url &";
167 auto pos = exec.find(
" ");
168 if (pos != std::string::npos)
169 fProg = exec.substr(0, pos);
172 fExec =
"open \'$url\'";
174 fExec =
"start $url";
176 fExec =
"xdg-open \'$url\' &";
185 if (nexttry.empty() || !fProg.empty())
190 fProg = std::regex_replace(nexttry, std::regex(
"%20"),
" ");
197 if (!check_std_paths)
202 auto pos = ProgramFiles.find(
" (x86)");
203 if (pos != std::string::npos)
204 ProgramFiles.erase(pos, 6);
205 std::string ProgramFilesx86 =
gSystem->
Getenv(
"ProgramFiles(x86)");
207 if (!ProgramFiles.empty())
208 TestProg(ProgramFiles + nexttry,
false);
209 if (!ProgramFilesx86.empty())
210 TestProg(ProgramFilesx86 + nexttry,
false);
217std::unique_ptr<RWebDisplayHandle>
225 std::cout <<
"New web window: " << url << std::endl;
226 return std::make_unique<RWebBrowserHandle>(url,
"",
"",
"");
233 exec = fHeadlessExec;
237 exec =
"$prog $url &";
242 std::string swidth = std::to_string(args.
GetWidth() > 0 ? args.
GetWidth() : 800),
244 sposx = std::to_string(args.
GetX() >= 0 ? args.
GetX() : 0),
245 sposy = std::to_string(args.
GetY() >= 0 ? args.
GetY() : 0);
247 ProcessGeometry(exec, args);
254 if (((url.find(
"token=") != std::string::npos) || (url.find(
"key=") != std::string::npos)) && !args.
IsBatchMode() && !args.
IsHeadless()) {
255 TString filebase =
"root_start_";
264 std::string content = std::regex_replace(
266 "<html lang=\"en\">\n"
268 " <meta charset=\"utf-8\">\n"
269 " <meta http-equiv=\"refresh\" content=\"0;url=$url\"/>\n"
270 " <title>Opening ROOT widget</title>\n"
274 " This page should redirect you to a ROOT widget. If it doesn't,\n"
275 " <a href=\"$url\">click here to go to ROOT</a>.\n"
278 "</html>\n", std::regex(
"\\$url"), url);
280 if (fwrite(content.c_str(), 1, content.length(),
f) != content.length())
286 tmpfile = filebase.
Data();
288 url =
"file://"s + tmpfile;
292 if (!tmpfile.empty())
299 exec = std::regex_replace(exec, std::regex(
"\\$rootetcdir"),
TROOT::GetEtcDir().Data());
300 exec = std::regex_replace(exec, std::regex(
"\\$url"), url);
301 exec = std::regex_replace(exec, std::regex(
"\\$width"), swidth);
302 exec = std::regex_replace(exec, std::regex(
"\\$height"), sheight);
303 exec = std::regex_replace(exec, std::regex(
"\\$posx"), sposx);
304 exec = std::regex_replace(exec, std::regex(
"\\$posy"), sposy);
306 if (exec.compare(0,5,
"fork:") == 0) {
308 if (!tmpfile.empty())
319 if (!fargs || (fargs->GetLast()<=0)) {
320 if (!tmpfile.empty())
326 std::vector<char *> argv;
327 argv.push_back((
char *) fProg.c_str());
328 for (
Int_t n = 0;
n <= fargs->GetLast(); ++
n)
329 argv.push_back((
char *)fargs->At(
n)->GetName());
330 argv.push_back(
nullptr);
332 R__LOG_DEBUG(0,
WebGUILog()) <<
"Show web window in browser with posix_spawn:\n" << fProg <<
" " << exec;
334 posix_spawn_file_actions_t action;
335 posix_spawn_file_actions_init(&action);
336 posix_spawn_file_actions_addopen (&action, STDOUT_FILENO,
"/dev/null", O_WRONLY|O_APPEND, 0);
337 posix_spawn_file_actions_addopen (&action, STDERR_FILENO,
"/dev/null", O_WRONLY|O_APPEND, 0);
340 int status = posix_spawn(&pid, argv[0], &action,
nullptr, argv.data(),
nullptr);
342 posix_spawn_file_actions_destroy(&action);
345 if (!tmpfile.empty())
353 return std::make_unique<RWebBrowserHandle>(url, rmdir, tmpfile, pid);
358 if (!tmpfile.empty())
365 exec =
"wmic process call create '"s +
gSystem->
UnixPathName(fProg.c_str()) +
" " + exec +
"' | find \"ProcessId\" "s;
367 std::stringstream ss(process_id);
371 ss >> tmp >>
c >> pid;
374 if (!tmpfile.empty())
381 return std::make_unique<RWebBrowserHandle>(url, rmdir, tmpfile, pid);
387 if (exec.rfind(
"&") == exec.length() - 1) {
390 exec.resize(exec.length() - 1);
392 std::vector<char *> argv;
393 std::string firstarg = fProg;
394 auto slashpos = firstarg.find_last_of(
"/\\");
395 if (slashpos != std::string::npos)
396 firstarg.erase(0, slashpos + 1);
397 argv.push_back((
char *)firstarg.c_str());
400 for (
Int_t n = 1;
n <= fargs->GetLast(); ++
n)
401 argv.push_back((
char *)fargs->At(
n)->GetName());
402 argv.push_back(
nullptr);
408 return std::make_unique<RWebBrowserHandle>(url, rmdir, tmpfile,
""s);
416 std::string prog = std::regex_replace(fProg, std::regex(
" "),
"\\ ");
418 std::string prog = fProg;
423 exec = std::regex_replace(exec, std::regex(
"\\$prog"), prog);
427 if (!redirect.empty()) {
428 if (exec.find(
"$dumpfile") != std::string::npos) {
429 exec = std::regex_replace(exec, std::regex(
"\\$dumpfile"), redirect);
431 auto p = exec.length();
432 if (exec.rfind(
"&") ==
p-1) --
p;
433 exec.insert(
p,
" >"s + redirect +
" "s);
442 if (!redirect.empty()) {
445 if (
gEnv->
GetValue(
"WebGui.PreserveBatchFiles", -1) > 0)
446 ::Info(
"RWebDisplayHandle::Display",
"Preserve dump file %s", redirect.c_str());
451 return std::make_unique<RWebBrowserHandle>(url, rmdir, tmpfile, dump_content);
490 TestProg(
"\\Microsoft\\Edge\\Application\\msedge.exe",
true);
492 TestProg(
"\\Google\\Chrome\\Application\\chrome.exe",
true);
495 TestProg(
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
499 TestProg(
"/usr/bin/chromium-browser");
500 TestProg(
"/usr/bin/chrome-browser");
501 TestProg(
"/usr/bin/google-chrome-stable");
515 bool use_normal =
true;
521 fBatchExec =
gEnv->
GetValue((
fEnvPrefix +
"Batch").c_str(),
"$prog --headless --no-sandbox --disable-extensions --disable-audio-output $geometry --dump-dom $url 2>/dev/null");
525 fBatchExec =
gEnv->
GetValue((
fEnvPrefix +
"Batch").c_str(),
"$prog --headless=new --no-sandbox --disable-extensions --disable-audio-output $geometry --dump-dom $url 2>/dev/null");
528 fExec =
gEnv->
GetValue((
fEnvPrefix +
"Interactive").c_str(),
"$prog $geometry --new-window --app=\'$url\' >/dev/null 2>/dev/null &");
547 geometry.append(
"--window-position="s + std::to_string(args.
GetX() >= 0 ? args.
GetX() : 0) +
","s +
548 std::to_string(args.
GetY() >= 0 ? args.
GetY() : 0));
556 exec = std::regex_replace(exec, std::regex(
"\\$geometry"),
geometry);
565 std::string rmdir, profile_arg;
567 if (exec.find(
"$profile") == std::string::npos)
570 const char *chrome_profile =
gEnv->
GetValue((fEnvPrefix +
"Profile").c_str(),
"");
571 if (chrome_profile && *chrome_profile) {
572 profile_arg = chrome_profile;
581 if (!profile_arg.empty() && (profile_arg[profile_arg.length()-1] !=
slash))
582 profile_arg +=
slash;
583 profile_arg +=
"root_chrome_profile_"s + std::to_string(
gRandom->
Integer(0x100000));
588 exec = std::regex_replace(exec, std::regex(
"\\$profile"), profile_arg);
602 TestProg(
"\\Mozilla Firefox\\firefox.exe",
true);
605 TestProg(
"/Applications/Firefox.app/Contents/MacOS/firefox");
617 fExec =
gEnv->
GetValue(
"WebGui.FirefoxInteractive",
"$prog -no-remote $profile $geometry $url &");
619 fBatchExec =
gEnv->
GetValue(
"WebGui.FirefoxBatch",
"$rootetcdir/runfirefox.sh $dumpfile $cleanup_profile $prog --headless -no-remote -new-instance $profile $url 2>/dev/null");
621 fExec =
gEnv->
GetValue(
"WebGui.FirefoxInteractive",
"$rootetcdir/runfirefox.sh __nodump__ $cleanup_profile $prog -no-remote $profile $geometry -url \'$url\' &");
634 exec = std::regex_replace(exec, std::regex(
"\\$geometry"),
geometry);
642 std::string rmdir, profile_arg;
644 if (exec.find(
"$profile") == std::string::npos)
647 const char *ff_profile =
gEnv->
GetValue(
"WebGui.FirefoxProfile",
"");
648 const char *ff_profilepath =
gEnv->
GetValue(
"WebGui.FirefoxProfilePath",
"");
650 if (ff_profile && *ff_profile) {
651 profile_arg =
"-P "s + ff_profile;
652 }
else if (ff_profilepath && *ff_profilepath) {
653 profile_arg =
"-profile "s + ff_profilepath;
654 }
else if (ff_randomprofile > 0) {
664 if (!profile_dir.empty() && (profile_dir[profile_dir.length()-1] !=
slash))
665 profile_dir +=
slash;
666 profile_dir +=
"root_ff_profile_"s + std::to_string(
gRandom->
Integer(0x100000));
668 profile_arg =
"-profile "s + profile_dir;
673 std::ofstream user_js(profile_dir +
"/user.js", std::ios::trunc);
676 user_js <<
"user_pref(\"datareporting.policy.dataSubmissionPolicyAcceptedVersion\", 2);" << std::endl;
677 user_js <<
"user_pref(\"datareporting.policy.dataSubmissionPolicyNotifiedTime\", \"1635760572813\");" << std::endl;
680 user_js <<
"user_pref(\"browser.tabs.closeWindowWithLastTab\", true);" << std::endl;
681 user_js <<
"user_pref(\"dom.allow_scripts_to_close_windows\", true);" << std::endl;
682 user_js <<
"user_pref(\"browser.sessionstore.resume_from_crash\", false);" << std::endl;
686 user_js <<
"user_pref(\"browser.dom.window.dump.enabled\", true);" << std::endl;
689 user_js <<
"user_pref(\"datareporting.policy.firstRunURL\", \"\");" << std::endl;
691 user_js <<
"user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", true);" << std::endl;
693 user_js <<
"user_pref(\"browser.tabs.inTitlebar\", 0);" << std::endl;
695 std::ofstream times_json(profile_dir +
"/times.json", std::ios::trunc);
696 times_json <<
"{" << std::endl;
697 times_json <<
" \"created\": 1699968480952," << std::endl;
698 times_json <<
" \"firstUse\": null" << std::endl;
699 times_json <<
"}" << std::endl;
700 if (
gSystem->
mkdir((profile_dir +
"/chrome").c_str()) == 0) {
701 std::ofstream
style(profile_dir +
"/chrome/userChrome.css", std::ios::trunc);
703 style <<
"#TabsToolbar { visibility: collapse; }" << std::endl;
705 style <<
"#nav-bar, #urlbar-container, #searchbar { visibility: collapse !important; }" << std::endl;
714 exec = std::regex_replace(exec, std::regex(
"\\$profile"), profile_arg);
716 if (exec.find(
"$cleanup_profile") != std::string::npos) {
717 if (rmdir.empty()) rmdir =
"__dummy__";
718 exec = std::regex_replace(exec, std::regex(
"\\$cleanup_profile"), rmdir);
739 auto &qt6 =
FindCreator(
"qt6",
"libROOTQt6WebDisplay");
740 if (qt6 && qt6->IsActive())
744 auto &qt5 =
FindCreator(
"qt5",
"libROOTQt5WebDisplay");
745 if (qt5 && qt5->IsActive())
749 auto &cef =
FindCreator(
"cef",
"libROOTCefDisplay");
750 if (cef && cef->IsActive())
767 std::unique_ptr<RWebDisplayHandle> handle;
772 auto try_creator = [&](std::unique_ptr<Creator> &creator) {
773 if (!creator || !creator->IsActive())
775 handle = creator->Display(args);
776 return handle ? true :
false;
781 has_qt5web =
false, has_qt6web =
false, has_cefweb =
false;
796 if (try_creator(
FindCreator(
"qt6",
"libROOTQt6WebDisplay")))
802 if (try_creator(
FindCreator(
"qt5",
"libROOTQt5WebDisplay")))
807 if (try_creator(
FindCreator(
"cef",
"libROOTCefDisplay")))
816 bool handleAsNative =
820 if (try_creator(
FindCreator(
"chrome",
"ChromeCreator")))
825 if (try_creator(
FindCreator(
"firefox",
"FirefoxCreator")))
832 if (try_creator(
FindCreator(
"edge",
"ChromeCreator")))
844 if (try_creator(
FindCreator(
"safari",
"SafariCreator")))
849 std::unique_ptr<Creator> creator = std::make_unique<BrowserCreator>(
false, args.
GetCustomExec());
850 try_creator(creator);
852 try_creator(
FindCreator(
"browser",
"BrowserCreator"));
890 bool detected =
false;
893 if (
h1 &&
h1->IsActive()) {
899 auto &h2 =
FindCreator(
"firefox",
"FirefoxCreator");
900 if (h2 && h2->IsActive()) {
911 return h1 &&
h1->IsActive();
915 auto &h2 =
FindCreator(
"firefox",
"FirefoxCreator");
916 return h2 && h2->IsActive();
922 return h3 && h3->IsActive();
947 std::string _fname = fname;
948 std::transform(_fname.begin(), _fname.end(), _fname.begin(), ::tolower);
949 auto EndsWith = [&_fname](
const std::string &suffix) {
950 return (_fname.length() > suffix.length()) ? (0 == _fname.compare(_fname.length() - suffix.length(), suffix.length(), suffix)) :
false;
953 if (EndsWith(
".screenshot.pdf"))
955 if (EndsWith(
".pdf"))
957 if (EndsWith(
".json"))
959 if (EndsWith(
".svg"))
961 if (EndsWith(
".screenshot.png"))
963 if (EndsWith(
".png"))
965 if (EndsWith(
".jpg") || EndsWith(
".jpeg"))
967 if (EndsWith(
".webp"))
992 std::vector<std::string> fnames;
994 if ((fmt ==
"s.pdf") || (fmt ==
"s.png")) {
995 fnames.emplace_back(fname);
997 std::string farg = fname;
999 bool has_quialifier = farg.find(
"%") != std::string::npos;
1001 if (!has_quialifier && (nfiles > 1) && (fmt !=
"pdf")) {
1002 farg.insert(farg.rfind(
"."),
"%d");
1003 has_quialifier =
true;
1006 for (
unsigned n = 0;
n < nfiles;
n++) {
1007 if(has_quialifier) {
1009 fnames.emplace_back(expand_name.Data());
1011 fnames.emplace_back(
"");
1013 fnames.emplace_back(fname);
1025bool RWebDisplayHandle::ProduceImages(
const std::string &fname,
const std::vector<std::string> &jsons,
const std::vector<int> &widths,
const std::vector<int> &heights,
const char *batch_file)
1034bool RWebDisplayHandle::ProduceImages(
const std::vector<std::string> &fnames,
const std::vector<std::string> &jsons,
const std::vector<int> &widths,
const std::vector<int> &heights,
const char *batch_file)
1036 if (fnames.empty() || jsons.empty())
1039 std::vector<std::string> fmts;
1040 for (
auto& fname : fnames)
1043 bool is_any_image =
false;
1045 for (
unsigned n = 0; (
n < fmts.size()) && (
n < jsons.size());
n++) {
1046 if (fmts[
n] ==
"json") {
1047 std::ofstream ofs(fnames[
n]);
1050 }
else if (!fmts[
n].empty())
1051 is_any_image =
true;
1058 if (fnames.size() == 1)
1071 jsrootsys = jsrootsysdflt.
Data();
1083 std::vector<std::string> draw_kinds;
1084 bool use_browser_draw =
false;
1087 if (fmts[0] ==
"s.png") {
1088 if (!isChromeBased && !isFirefox) {
1089 R__LOG_ERROR(
WebGUILog()) <<
"Direct png image creation supported only by Chrome and Firefox browsers";
1092 use_browser_draw =
true;
1094 }
else if (fmts[0] ==
"s.pdf") {
1095 if (!isChromeBased) {
1099 use_browser_draw =
true;
1106 if (!batch_file || !*batch_file)
1107 batch_file =
"/js/files/canv_batch.htm";
1116 if (filecont.empty()) {
1121 int max_width = 0, max_height = 0, page_margin = 10;
1122 for (
auto &
w : widths)
1125 for (
auto &
h : heights)
1133 for (
auto &
json : jsons) {
1134 mains.append(mains.empty() ?
"[" :
", ");
1139 if (strstr(jsrootsys,
"http://") || strstr(jsrootsys,
"https://") || strstr(jsrootsys,
"file://"))
1140 filecont = std::regex_replace(filecont, std::regex(
"\\$jsrootsys"), jsrootsys);
1142 static std::string jsroot_include =
"<script id=\"jsroot\" src=\"$jsrootsys/build/jsroot.js\"></script>";
1143 auto p = filecont.find(jsroot_include);
1144 if (
p != std::string::npos) {
1146 if (!jsroot_build.empty()) {
1148 jsroot_build = std::regex_replace(jsroot_build, std::regex(
"'\\$jsrootsys'"), std::string(
"'file://") + jsrootsys +
"/'");
1149 filecont.erase(
p, jsroot_include.length());
1150 filecont.insert(
p,
"<script id=\"jsroot\">" + jsroot_build +
"</script>");
1154 filecont = std::regex_replace(filecont, std::regex(
"\\$jsrootsys"),
"file://"s + jsrootsys);
1157 filecont = std::regex_replace(filecont, std::regex(
"\\$page_margin"), std::to_string(page_margin) +
"px");
1158 filecont = std::regex_replace(filecont, std::regex(
"\\$page_width"), std::to_string(max_width + 2*page_margin) +
"px");
1159 filecont = std::regex_replace(filecont, std::regex(
"\\$page_height"), std::to_string(max_height + 2*page_margin) +
"px");
1161 filecont = std::regex_replace(filecont, std::regex(
"\\$draw_kind"), jsonkind.
Data());
1162 filecont = std::regex_replace(filecont, std::regex(
"\\$draw_widths"), jsonw.Data());
1163 filecont = std::regex_replace(filecont, std::regex(
"\\$draw_heights"), jsonh.Data());
1164 filecont = std::regex_replace(filecont, std::regex(
"\\$draw_objects"), mains);
1167 if (!use_browser_draw && (isChromeBased || isFirefox)) {
1168 dump_name =
"canvasdump";
1174 fputs(
"placeholder", df);
1180 static bool chrome_tmp_workaround =
false;
1193 R__LOG_DEBUG(0,
WebGUILog()) <<
"Using file content_len " << filecont.length() <<
" to produce batch images ";
1196 tmp_name =
"canvasbody";
1202 fputs(filecont.c_str(), hf);
1205 html_name = tmp_name +
".html";
1207 if (chrome_tmp_workaround) {
1209 auto pos = html_name.
Last(
'/');
1213 html_name.
Remove(0, pos);
1214 html_name = homedir + html_name.
Data();
1218 std::ofstream ofs(html_name.
Data(), std::ofstream::out);
1231 R__LOG_DEBUG(0,
WebGUILog()) <<
"Using " << html_name <<
" content_len " << filecont.length() <<
" to produce batch images " << fdebug;
1234 TString wait_file_name, tgtfilename;
1239 args.
SetSize(widths[0], heights[0]);
1241 if (use_browser_draw) {
1243 tgtfilename = fnames[0].c_str();
1247 wait_file_name = tgtfilename;
1249 if (fmts[0] ==
"s.pdf")
1251 else if (isFirefox) {
1253 wait_file_name =
"screenshot.png";
1260 }
else if (isFirefox) {
1264 }
else if (isChromeBased) {
1278 if (html_name.
Length() > 0) {
1279 if (
gEnv->
GetValue(
"WebGui.PreserveBatchFiles", -1) > 0)
1280 ::Info(
"ProduceImages",
"Preserve batch file %s", html_name.
Data());
1290 if (use_browser_draw) {
1291 if (fmts[0] ==
"s.pdf")
1292 ::Info(
"ProduceImages",
"PDF file %s with %d pages has been created", fnames[0].c_str(), (
int) jsons.size());
1296 ::Info(
"ProduceImages",
"PNG file %s with %d pages has been created", fnames[0].c_str(), (
int) jsons.size());
1299 auto dumpcont = handle->GetContent();
1301 if ((dumpcont.length() > 20) && (dumpcont.length() < 60) && !chrome_tmp_workaround && isChromeBased) {
1305 printf(
"Handle chrome workaround\n");
1306 chrome_tmp_workaround =
true;
1310 if (dumpcont.length() < 100) {
1315 std::string::size_type
p = 0;
1317 for (
unsigned n = 0;
n < fmts.size();
n++) {
1318 if (fmts[
n].empty())
1320 if (fmts[
n] ==
"svg") {
1321 auto p1 = dumpcont.find(
"<svg",
p);
1322 auto p2 = dumpcont.find(
"</svg></div>", p1 + 4);
1324 std::ofstream ofs(fnames[
n]);
1325 if ((p1 != std::string::npos) && (p2 != std::string::npos) && (p1 < p2)) {
1326 ofs << dumpcont.substr(p1, p2-p1+6);
1327 ::Info(
"ProduceImages",
"SVG file %s size %d bytes has been created", fnames[
n].c_str(), (
int) (p2-p1+6));
1330 ofs <<
"Failure!!!\n" << dumpcont;
1334 auto p1 = dumpcont.find(
";base64,",
p);
1335 auto p2 = dumpcont.find(
"></div>", p1 + 4);
1338 if ((p1 != std::string::npos) && (p2 != std::string::npos) && (p1 < p2)) {
1339 auto base64 = dumpcont.substr(p1+8, p2-p1-9);
1342 std::ofstream ofs(fnames[
n], std::ios::binary);
1343 ofs.write(binary.Data(), binary.Length());
1345 ::Info(
"ProduceImages",
"Image file %s size %d bytes has been created", fnames[
n].c_str(), (
int) binary.Length());
#define R__LOG_ERROR(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
winID h TVirtualViewer3D TVirtualGLPainter p
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 TRandom * gRandom
R__EXTERN TSystem * gSystem
Specialized handle to hold information about running browser process Used to correctly cleanup all pr...
RWebBrowserHandle(const std::string &url, const std::string &tmpdir, const std::string &tmpfile, browser_process_id pid)
std::string fTmpDir
temporary directory to delete at the end
RWebBrowserHandle(const std::string &url, const std::string &tmpdir, const std::string &tmpfile, const std::string &dump)
std::string fTmpFile
temporary file to remove
~RWebBrowserHandle() override
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
std::string GetBrowserName() const
Returns configured browser name.
EBrowserKind GetBrowserKind() const
returns configured browser kind, see EBrowserKind for supported values
const std::string & GetRedirectOutput() const
get file name to which web browser output should be redirected
void SetStandalone(bool on=true)
Set standalone mode for running browser, default on When disabled, normal browser window (or just tab...
void SetBatchMode(bool on=true)
set batch mode
RWebDisplayArgs & SetSize(int w, int h)
set preferable web window width and height
RWebDisplayArgs & SetUrl(const std::string &url)
set window url
int GetWidth() const
returns preferable web window width
RWebDisplayArgs & SetPageContent(const std::string &cont)
set window url
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
RWebDisplayArgs & SetBrowserKind(const std::string &kind)
Set browser kind as string argument.
std::string GetCustomExec() const
returns custom executable to start web browser
void SetExtraArgs(const std::string &args)
set extra command line arguments for starting web browser command
bool IsBatchMode() const
returns batch mode
bool IsHeadless() const
returns headless mode
@ kOn
web display enable, first try use embed displays like Qt or CEF, then native browsers and at the end ...
@ kFirefox
Mozilla Firefox browser.
@ kNative
either Chrome or Firefox - both support major functionality
@ kLocal
either CEF or Qt5 - both runs on local display without real http server
@ kServer
indicates that ROOT runs as server and just printouts window URL, browser should be started by the us...
@ kOff
disable web display, do not start any browser
@ kCEF
Chromium Embedded Framework - local display with CEF libs.
@ kQt5
Qt5 QWebEngine libraries - Chromium code packed in qt5.
@ kQt6
Qt6 QWebEngine libraries - Chromium code packed in qt6.
@ kCustom
custom web browser, execution string should be provided
@ kChrome
Google Chrome browser.
@ kEdge
Microsoft Edge browser (Windows only)
void SetRedirectOutput(const std::string &fname="")
specify file name to which web browser output should be redirected
void SetHeadless(bool on=true)
set 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
bool IsLocalDisplay() const
returns true if local display like CEF or Qt5 QWebEngine should be used
std::string fProg
browser executable
std::string fBatchExec
batch execute line
std::string fHeadlessExec
headless execute line
std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args) override
Display given URL in web browser.
std::string fExec
standard execute line
void TestProg(const std::string &nexttry, bool check_std_paths=false)
Check if browser executable exists and can be used.
BrowserCreator(bool custom=true, const std::string &exec="")
Class to handle starting of web-browsers like Chrome or Firefox.
ChromeCreator(bool is_edge=false)
Constructor.
void ProcessGeometry(std::string &, const RWebDisplayArgs &) override
Replace $geometry placeholder with geometry settings Also RWebDisplayArgs::GetExtraArgs() are appende...
std::string MakeProfile(std::string &exec, bool) override
Handle profile argument.
FirefoxCreator()
Constructor.
std::string MakeProfile(std::string &exec, bool batch) override
Create Firefox profile to run independent browser window.
void ProcessGeometry(std::string &, const RWebDisplayArgs &) override
Process window geometry for Firefox.
bool IsActive() const override
Returns true if it can be used.
SafariCreator()
Constructor.
Handle of created web-based display Depending from type of web display, holds handle of started brows...
static std::map< std::string, std::unique_ptr< Creator > > & GetMap()
Static holder of registered creators of web displays.
static bool CheckIfCanProduceImages(RWebDisplayArgs &args)
Checks if configured browser can be used for image production.
static bool ProduceImages(const std::string &fname, const std::vector< std::string > &jsons, const std::vector< int > &widths, const std::vector< int > &heights, const char *batch_file=nullptr)
Produce image file(s) using JSON data as source Invokes JSROOT drawing functionality in headless brow...
static std::vector< std::string > ProduceImagesNames(const std::string &fname, unsigned nfiles=1)
Produce vector of file names for specified file pattern Depending from supported file forma.
static std::string GetImageFormat(const std::string &fname)
Detect image format There is special handling of ".screenshot.pdf" and ".screenshot....
void SetContent(const std::string &cont)
set content
static bool ProduceImage(const std::string &fname, const std::string &json, int width=800, int height=600, const char *batch_file=nullptr)
Produce image file using JSON data as source Invokes JSROOT drawing functionality in headless browser...
static bool CanProduceImages(const std::string &browser="")
Returns true if image production for specified browser kind is supported If browser not specified - u...
static bool NeedHttpServer(const RWebDisplayArgs &args)
Check if http server required for display.
static bool DisplayUrl(const std::string &url)
Display provided url in configured web browser.
static std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args)
Create web display.
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.
static TString Decode(const char *data)
Decode a base64 string date into a generic TString.
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
@ kNoSpaces
no new lines plus remove all spaces around "," and ":" symbols
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
static char * ReadFileContent(const char *filename, Int_t &len)
Reads content of file from the disk.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
void Clear()
Clear string without changing its capacity.
const char * Data() const
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
TString & Remove(Ssiz_t pos)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr)
Create a secure temporary file by appending a unique 6 letter string to base.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual std::string GetHomeDirectory(const char *userName=nullptr) const
Return the user's home directory.
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
virtual int Rename(const char *from, const char *to)
Rename a file.
virtual TString GetFromPipe(const char *command)
Execute command and return output in TString.
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
virtual const char * WorkingDirectory()
Return working directory.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
ROOT::Experimental::RLogChannel & WebGUILog()
Log channel for WebGUI diagnostics.