diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/00-Delete.bat b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/00-Delete.bat
new file mode 100644
index 00000000..0b5ba5c8
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/00-Delete.bat
@@ -0,0 +1,2 @@
+rmdir /S /Q lib
+rmdir /S /Q backup
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.ico b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.ico
new file mode 100644
index 00000000..25c186a5
Binary files /dev/null and b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.ico differ
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.lpi b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.lpi
new file mode 100644
index 00000000..d948d88f
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.lpi
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.lpr b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.lpr
new file mode 100644
index 00000000..d0d2e185
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.lpr
@@ -0,0 +1,73 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+program AppHelper;
+
+(*
+ * The compiled exe should be copied into
+ * SimpleBrowser.app/Content/Frameworks/SimpleBrowser2 Helper.app/Content/MacOS/SimpleBrowser2 Helper
+ * including app bundle in SimpleBrowser2.app/Content/Frameworks/SimpleBrowser2 Helper.app
+ *)
+
+{$mode objfpc}{$H+}
+
+{$I cef.inc}
+
+uses
+ {$IFDEF UNIX}
+ cthreads,
+ {$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ uHelperProcessDom,
+ uCEFApplication, uCEFTypes, uCEFConstants, LazFileUtils, sysutils;
+
+begin
+ GlobalCEFApp := TCefApplication.Create;
+ InitProcessMessagesHandler;
+
+ // The main process and the subprocess *MUST* have the same GlobalCEFApp
+ // properties and events, specially FrameworkDirPath, ResourcesDirPath,
+ // LocalesDirPath, cache and UserDataPath paths.
+ {$IFDEF MACOSX}
+ GlobalCEFApp.InitLibLocationFromArgs;
+ {$ENDIF}
+
+ GlobalCEFApp.StartSubProcess;
+ GlobalCEFApp.Free;
+ GlobalCEFApp := nil;
+end.
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.res b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.res
new file mode 100644
index 00000000..bcdc0667
Binary files /dev/null and b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/AppHelper.res differ
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/cef.inc b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/cef.inc
new file mode 100644
index 00000000..c8ce967e
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/cef.inc
@@ -0,0 +1,468 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2017 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+ // The complete list of compiler versions is here :
+ // http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions
+
+{$DEFINE DELPHI_VERSION_UNKNOW}
+
+// Delphi 5
+{$IFDEF VER130}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+{$ENDIF}
+
+// Delphi 6
+{$IFDEF VER140}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+{$ENDIF}
+
+// Delphi 7
+{$IFDEF VER150}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+{$ENDIF}
+
+// Delphi 8
+{$IFDEF VER160}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+{$ENDIF}
+
+// Delphi 2005
+{$IFDEF VER170}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+{$ENDIF}
+
+{$IFDEF VER180}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ // Delphi 2007
+ {$IFDEF VER185}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ // Delphi 2006
+ {$ELSE}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$ENDIF}
+{$ENDIF}
+
+// Delphi 2009
+{$IFDEF VER200}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+{$ENDIF}
+
+//Delphi 2010
+{$IFDEF VER210}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+{$ENDIF}
+
+// Delphi XE
+{$IFDEF VER220}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+{$ENDIF}
+
+// Delphi XE2 (First FireMonkey and 64bit compiler)
+{$IFDEF VER230}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+{$ENDIF}
+
+// Delphi XE3
+{$IFDEF VER240}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+{$ENDIF}
+
+// Delphi XE4
+{$IFDEF VER250}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+{$ENDIF}
+
+// Delphi XE5
+{$IFDEF VER260}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+{$ENDIF}
+
+// Delphi XE6
+{$IFDEF VER270}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+{$ENDIF}
+
+// Delphi XE7
+{$IFDEF VER280}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+{$ENDIF}
+
+// Delphi XE8
+{$IFDEF VER290}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+{$ENDIF VER290}
+
+// Rad Studio 10 - Delphi Seattle
+{$IFDEF VER300}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+{$ENDIF}
+
+// Rad Studio 10.1 - Delphi Berlin
+{$IFDEF VER310}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+{$ENDIF}
+
+// Rad Studio 10.2 - Delphi Tokyo
+{$IFDEF VER320}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+{$ENDIF}
+
+// Rad Studio 10.3 - Delphi Rio
+{$IFDEF VER330}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+ {$DEFINE DELPHI26_UP}
+{$ENDIF}
+
+// Rad Studio 10.4 - Delphi Sydney
+{$IFDEF VER340}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+ {$DEFINE DELPHI26_UP}
+ {$DEFINE DELPHI27_UP}
+{$ENDIF}
+
+{$IFDEF FPC}
+ {$DEFINE SUPPORTS_INLINE}
+ {$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
+ {$DEFINE FPC_VER_320}
+ {$IFEND}
+{$ELSE}
+ {$IFDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+ {$DEFINE DELPHI26_UP}
+ {$DEFINE DELPHI27_UP}
+ {$ENDIF}
+{$ENDIF}
+
+{$IFDEF DELPHI9_UP}
+ {$DEFINE SUPPORTS_INLINE}
+{$ENDIF}
+
+{$IF DEFINED(CPUX32) OR
+ DEFINED(CPU386) OR
+ DEFINED(CPUi386) OR
+ DEFINED(CPUPOWERPC32) OR
+ DEFINED(CPUSPARC32) OR
+ DEFINED(CPU32BITS) OR
+ DEFINED(CPUARM32) OR
+ DEFINED(WIN32) OR
+ DEFINED(IOS32) OR
+ DEFINED(MACOS32) OR
+ DEFINED(LINUX32) OR
+ DEFINED(POSIX32) OR
+ DEFINED(ANDROID32)}
+ {$DEFINE TARGET_32BITS}
+{$IFEND}
+
+// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
+// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
+// We define MACOSX to avoid conflicts in both situations
+{$IFDEF FPC}
+ {$IFDEF DARWIN}
+ {$DEFINE MACOSX}
+ {$ENDIF}
+{$ELSE}
+ {$IFDEF MACOS}
+ {$DEFINE MACOSX}
+ {$ENDIF}
+{$ENDIF}
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/create_mac_helper_apps.sh b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/create_mac_helper_apps.sh
new file mode 100755
index 00000000..eb60983c
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/AppHelper/create_mac_helper_apps.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+BASEDIR=$(dirname "$0")
+DEST=$1
+SRC=$2
+
+if [ "$SRC" = "" ];
+then
+ SRC=$BASEDIR/../../../../bin/AppHelper.app
+fi
+
+if [ "$1" = "" ] || [ ! -e "$DEST" ] || [ ! -e "$SRC" ];
+then
+ echo "Usage"
+ echo " $0 destpath/project.app"
+ echo " $0 destpath/project.app sourcedir/AppHelper.app"
+ echo
+ if [ ! -e "$DEST" ];
+ then
+ echo "Error: Target app bundle not found. (Did you compile AND create the bundle?)"
+ fi
+ if [ ! -e "$SRC" ];
+ then
+ echo "Error: Source (AppHelper) app bundle not found. (Did you compile AND create the bundle?)"
+ fi
+ exit;
+fi
+
+SRCAPP=$(basename "$SRC")
+SRCAPP="${SRCAPP%\.app}"
+DESTAPP=$(basename "$DEST")
+DESTAPP="${DESTAPP%\.app}"
+
+SUB=""
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
+SUB=" (GPU)"
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
+SUB=" (Renderer)"
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
+SUB=" (Plugin)"
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.ico b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.ico
new file mode 100644
index 00000000..0341321b
Binary files /dev/null and b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.ico differ
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.lpi b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.lpi
new file mode 100644
index 00000000..3ec9b24d
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.lpi
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.lpr b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.lpr
new file mode 100644
index 00000000..3e8fa958
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.lpr
@@ -0,0 +1,84 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2018 Salvador DÃaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+
+ (*
+ * Include the following files
+ * BrowserWindow.app/Contents/Frameworks/ExternalPumpBrowser Helper.app/
+ * files from the demos/Lazarus_Mac/AppHelper project
+ * use create_mac_helper.sh
+ *
+ * BrowserWindow.app/Contents/Frameworks/Chromium Embedded Framework.framework
+ * files from Release folder in cef download
+ *
+ *)
+
+
+program BrowserWindowDom;
+
+{$mode objfpc}{$H+}
+{$I cef.inc}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ {$IFDEF LINUX}
+ InitSubProcess, // On Linux this unit must be used *before* the "interfaces" unit.
+ {$ENDIF}
+ Interfaces,
+ Forms,
+ uBrowserWindowDom, GlobalCefApplication,
+ uHelperProcessDom // Used here, for any OS where the main exe server as AppHelper too.
+ { you can add units after this }
+ ;
+
+{$R *.res}
+
+{$IFDEF WIN32}
+ // CEF needs to set the LARGEADDRESSAWARE ($20) flag which allows 32-bit processes to use up to 3GB of RAM.
+ {$SetPEFlags $20}
+{$ENDIF}
+
+begin
+ RequireDerivedFormResource:=True;
+ Application.Scaled := True;
+ Application.Initialize;
+ Application.CreateForm(TForm1, Form1);
+ Application.Run;
+end.
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.res b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.res
new file mode 100644
index 00000000..bec39b4a
Binary files /dev/null and b/demos/Lazarus_any_OS/BrowserWindowDom/BrowserWindowDom.res differ
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/README.txt b/demos/Lazarus_any_OS/BrowserWindowDom/README.txt
new file mode 100644
index 00000000..728911ff
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/README.txt
@@ -0,0 +1,40 @@
+BrowserWindow
+
+# ABOUT
+
+This example uses
+ TLazarusBrowserWindow
+ Examining DOM
+
+TCEFWorkScheduler feeds the CEF messageloop by calling DoMessageLoopWork(). On Mac this is currently the only way to run the CEF messageloop.
+
+
+# SETUP
+
+** Windows
+1) Download the CEF framework and place the content of the "Release" folder into the same folder as your exe.
+ Alternatively you can point "GlobalCEFApp.FrameworkDirPath" to the location with the libraries.
+2) Run the project
+
+** Linux
+1) Download the CEF framework and place the content of the "Release" folder into the same folder as your exe.
+ Alternatively you can point "GlobalCEFApp.FrameworkDirPath" to the location with the libraries.
+2) Run the project
+
+Note:
+- For your own Linux project you must modify the project source (lpr) and add "InitSubProcess" to the "uses" clause, so that it is in the list *before* the unit "Interfaces".
+- The call to "DestroyGlobalCEFApp" must be in a unit *not* used by "unit InitSubProcess" (including not used in any nested way).
+
+
+** Mac
+1) Go to "project options" and create the "App Bundle"
+2) Download the CEF framework and place the content of the "Release" folder into ExternalPumpBrowser.app/Contents/Frameworks/Chromium Embedded Framework.framework
+You should have:
+ Chromium Embedded Framework
+ Libraries/*
+ Resources/*
+3) Open project "AppHelper" (from the subfolder in this project's folder), create App Bundle and compile the AppHelper.
+ Run create_mac_helper.sh
+4) Open project ExternalPumpBrowser, compile and run
+
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/cef.inc b/demos/Lazarus_any_OS/BrowserWindowDom/cef.inc
new file mode 100644
index 00000000..c8ce967e
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/cef.inc
@@ -0,0 +1,468 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2017 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+ // The complete list of compiler versions is here :
+ // http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions
+
+{$DEFINE DELPHI_VERSION_UNKNOW}
+
+// Delphi 5
+{$IFDEF VER130}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+{$ENDIF}
+
+// Delphi 6
+{$IFDEF VER140}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+{$ENDIF}
+
+// Delphi 7
+{$IFDEF VER150}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+{$ENDIF}
+
+// Delphi 8
+{$IFDEF VER160}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+{$ENDIF}
+
+// Delphi 2005
+{$IFDEF VER170}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+{$ENDIF}
+
+{$IFDEF VER180}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ // Delphi 2007
+ {$IFDEF VER185}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ // Delphi 2006
+ {$ELSE}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$ENDIF}
+{$ENDIF}
+
+// Delphi 2009
+{$IFDEF VER200}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+{$ENDIF}
+
+//Delphi 2010
+{$IFDEF VER210}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+{$ENDIF}
+
+// Delphi XE
+{$IFDEF VER220}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+{$ENDIF}
+
+// Delphi XE2 (First FireMonkey and 64bit compiler)
+{$IFDEF VER230}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+{$ENDIF}
+
+// Delphi XE3
+{$IFDEF VER240}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+{$ENDIF}
+
+// Delphi XE4
+{$IFDEF VER250}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+{$ENDIF}
+
+// Delphi XE5
+{$IFDEF VER260}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+{$ENDIF}
+
+// Delphi XE6
+{$IFDEF VER270}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+{$ENDIF}
+
+// Delphi XE7
+{$IFDEF VER280}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+{$ENDIF}
+
+// Delphi XE8
+{$IFDEF VER290}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+{$ENDIF VER290}
+
+// Rad Studio 10 - Delphi Seattle
+{$IFDEF VER300}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+{$ENDIF}
+
+// Rad Studio 10.1 - Delphi Berlin
+{$IFDEF VER310}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+{$ENDIF}
+
+// Rad Studio 10.2 - Delphi Tokyo
+{$IFDEF VER320}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+{$ENDIF}
+
+// Rad Studio 10.3 - Delphi Rio
+{$IFDEF VER330}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+ {$DEFINE DELPHI26_UP}
+{$ENDIF}
+
+// Rad Studio 10.4 - Delphi Sydney
+{$IFDEF VER340}
+ {$UNDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+ {$DEFINE DELPHI26_UP}
+ {$DEFINE DELPHI27_UP}
+{$ENDIF}
+
+{$IFDEF FPC}
+ {$DEFINE SUPPORTS_INLINE}
+ {$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
+ {$DEFINE FPC_VER_320}
+ {$IFEND}
+{$ELSE}
+ {$IFDEF DELPHI_VERSION_UNKNOW}
+ {$DEFINE DELPHI5_UP}
+ {$DEFINE DELPHI6_UP}
+ {$DEFINE DELPHI7_UP}
+ {$DEFINE DELPHI8_UP}
+ {$DEFINE DELPHI9_UP}
+ {$DEFINE DELPHI10_UP}
+ {$DEFINE DELPHI11_UP}
+ {$DEFINE DELPHI12_UP}
+ {$DEFINE DELPHI14_UP}
+ {$DEFINE DELPHI15_UP}
+ {$DEFINE DELPHI16_UP}
+ {$DEFINE DELPHI17_UP}
+ {$DEFINE DELPHI18_UP}
+ {$DEFINE DELPHI19_UP}
+ {$DEFINE DELPHI20_UP}
+ {$DEFINE DELPHI21_UP}
+ {$DEFINE DELPHI22_UP}
+ {$DEFINE DELPHI23_UP}
+ {$DEFINE DELPHI24_UP}
+ {$DEFINE DELPHI25_UP}
+ {$DEFINE DELPHI26_UP}
+ {$DEFINE DELPHI27_UP}
+ {$ENDIF}
+{$ENDIF}
+
+{$IFDEF DELPHI9_UP}
+ {$DEFINE SUPPORTS_INLINE}
+{$ENDIF}
+
+{$IF DEFINED(CPUX32) OR
+ DEFINED(CPU386) OR
+ DEFINED(CPUi386) OR
+ DEFINED(CPUPOWERPC32) OR
+ DEFINED(CPUSPARC32) OR
+ DEFINED(CPU32BITS) OR
+ DEFINED(CPUARM32) OR
+ DEFINED(WIN32) OR
+ DEFINED(IOS32) OR
+ DEFINED(MACOS32) OR
+ DEFINED(LINUX32) OR
+ DEFINED(POSIX32) OR
+ DEFINED(ANDROID32)}
+ {$DEFINE TARGET_32BITS}
+{$IFEND}
+
+// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
+// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
+// We define MACOSX to avoid conflicts in both situations
+{$IFDEF FPC}
+ {$IFDEF DARWIN}
+ {$DEFINE MACOSX}
+ {$ENDIF}
+{$ELSE}
+ {$IFDEF MACOS}
+ {$DEFINE MACOSX}
+ {$ENDIF}
+{$ENDIF}
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/create_mac_helper.sh b/demos/Lazarus_any_OS/BrowserWindowDom/create_mac_helper.sh
new file mode 100755
index 00000000..49927781
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/create_mac_helper.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+CDIR=$(pwd)
+cd "$(dirname "$0")"
+
+./AppHelper/create_mac_helper_apps.sh ../../../bin/BrowserWindowDom.app
+
+if [ "$(grep -i TCrCocoaApplication ../../../bin/BrowserWindowDom.app/Contents/Info.plist)" = "" ];
+then
+sed -i '' "1,4s//\n NSPrincipalClass<\/key>\n TCrCocoaApplication<\/string>/" ../../../bin/BrowserWindowDom.app/Contents/Info.plist
+fi
+
+cd "$CDIR"
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/globalcefapplication.pas b/demos/Lazarus_any_OS/BrowserWindowDom/globalcefapplication.pas
new file mode 100644
index 00000000..6302bb21
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/globalcefapplication.pas
@@ -0,0 +1,118 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+unit GlobalCefApplication;
+
+{$mode ObjFPC}{$H+}
+{$I cef.inc}
+
+{.$DEFINE USE_MULTI_THREAD_LOOP} // Only Windows/Linux
+{.$DEFINE USE_APP_HELPER} // Optional on Windows/Linux
+
+{$IFDEF MACOSX}
+ {$UNDEF USE_MULTI_THREAD_LOOP} // Will fail on Mac
+ {$DEFINE USE_APP_HELPER} // Required on Mac
+{$ENDIF}
+
+interface
+
+uses
+ uCEFApplication, uCEFWorkScheduler, uCEFLazApplication, FileUtil,
+ uHelperProcessDom;
+
+procedure CreateGlobalCEFApp;
+
+implementation
+
+procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
+begin
+ if (GlobalCEFWorkScheduler <> nil) then GlobalCEFWorkScheduler.ScheduleMessagePumpWork(aDelayMS);
+end;
+
+procedure CreateGlobalCEFApp;
+begin
+ if GlobalCEFApp <> nil then
+ exit;
+
+ {$IFnDEF USE_MULTI_THREAD_LOOP}
+ // TCEFWorkScheduler will call cef_do_message_loop_work when
+ // it's told in the GlobalCEFApp.OnScheduleMessagePumpWork event.
+ // GlobalCEFWorkScheduler needs to be created before the
+ // GlobalCEFApp.StartMainProcess call.
+ GlobalCEFWorkScheduler := TCEFWorkScheduler.Create(nil);
+ {$ENDIF}
+
+ GlobalCEFApp := TCefLazApplication.Create;
+ GlobalCEFApp.CheckCEFFiles := False;
+ {$IFDEF USE_MULTI_THREAD_LOOP}
+ // On Windows/Linux CEF can use threads for the message-loop
+ GlobalCEFApp.MultiThreadedMessageLoop := True;
+ {$ELSE}
+ // use External Pump for message-loop
+ GlobalCEFApp.ExternalMessagePump := True;
+ GlobalCEFApp.MultiThreadedMessageLoop := False;
+ GlobalCEFApp.OnScheduleMessagePumpWork := @GlobalCEFApp_OnScheduleMessagePumpWork;
+ {$ENDIF}
+
+ {$IFnDEF MACOSX}
+ {$IFDEF USE_APP_HELPER}
+ (* Use AppHelper as subprocess, instead of the main exe *)
+ GlobalCEFApp.BrowserSubprocessPath := 'AppHelper' + GetExeExt;
+ {$ENDIF}
+ {$ENDIF}
+
+ {$IFDEF MACOSX}
+ (* Enable the below to prevent being asked for permission to access "Chromium Safe Storage"
+ If set to true, Cookies will not be encrypted.
+ *)
+ GlobalCEFApp.UseMockKeyChain := True;
+ {$ENDIF}
+ {$IFDEF LINUX}
+ // This is a workaround for the 'GPU is not usable error' issue :
+ // https://bitbucket.org/chromiumembedded/cef/issues/2964/gpu-is-not-usable-error-during-cef
+ GlobalCEFApp.DisableZygote := True; // this property adds the "--no-zygote" command line switch
+ {$ENDIF}
+ {
+ GlobalCEFApp.LogFile := 'cef.log';
+ GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
+ }
+
+ InitProcessMessagesHandler; // This is for the AppHelper process.
+end;
+
+end.
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/initsubprocess.pas b/demos/Lazarus_any_OS/BrowserWindowDom/initsubprocess.pas
new file mode 100644
index 00000000..512c43e8
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/initsubprocess.pas
@@ -0,0 +1,61 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+unit InitSubProcess;
+
+{$mode ObjFPC}{$H+}
+{$I cef.inc}
+
+interface
+
+uses
+ GlobalCefApplication, uCEFApplication, uCEFWorkScheduler;
+
+implementation
+
+initialization
+ CreateGlobalCEFApp;
+ if not GlobalCEFApp.StartMainProcess then begin
+ if GlobalCEFWorkScheduler <> nil then
+ GlobalCEFWorkScheduler.StopScheduler;
+ DestroyGlobalCEFApp;
+ DestroyGlobalCEFWorkScheduler;
+ halt(0); // exit the subprocess
+ end;
+
+end.
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/uBrowserWindowDom.lfm b/demos/Lazarus_any_OS/BrowserWindowDom/uBrowserWindowDom.lfm
new file mode 100644
index 00000000..09e1ab2d
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/uBrowserWindowDom.lfm
@@ -0,0 +1,73 @@
+object Form1: TForm1
+ Left = 473
+ Height = 589
+ Top = 227
+ Width = 967
+ Caption = 'Initializing browser. Please wait...'
+ ClientHeight = 589
+ ClientWidth = 967
+ OnCloseQuery = FormCloseQuery
+ OnCreate = FormCreate
+ Position = poScreenCenter
+ LCLVersion = '2.1.0.0'
+ object AddressPnl: TPanel
+ Left = 0
+ Height = 23
+ Top = 0
+ Width = 967
+ Align = alTop
+ BevelOuter = bvNone
+ ClientHeight = 23
+ ClientWidth = 967
+ TabOrder = 0
+ object GoBtn: TButton
+ Left = 932
+ Height = 23
+ Top = 0
+ Width = 35
+ Align = alRight
+ Caption = 'Go'
+ OnClick = GoBtnClick
+ TabOrder = 0
+ end
+ object AddressEdt: TComboBox
+ Left = 0
+ Height = 23
+ Top = 0
+ Width = 932
+ Align = alClient
+ ItemHeight = 15
+ ItemIndex = 0
+ Items.Strings = (
+ 'https://www.google.com'
+ 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending'
+ 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close'
+ 'https://www.w3schools.com/html/html5_video.asp'
+ 'http://www.adobe.com/software/flash/about/'
+ 'http://isflashinstalled.com/'
+ 'chrome://version/'
+ 'http://html5test.com/'
+ 'https://www.w3schools.com/'
+ 'http://webglsamples.org/'
+ 'https://get.webgl.org/'
+ 'https://www.youtube.com'
+ 'https://html5demos.com/drag/'
+ 'https://developers.google.com/maps/documentation/javascript/examples/streetview-embed?hl=fr'
+ 'https://www.w3schools.com/Tags/tryit.asp?filename=tryhtml_iframe_name'
+ 'https://www.browserleaks.com/webrtc'
+ 'https://frames-per-second.appspot.com/'
+ )
+ TabOrder = 1
+ Text = 'https://www.google.com'
+ end
+ end
+ object LazarusBrowserWindow1: TLazarusBrowserWindow
+ Left = 0
+ Height = 566
+ Top = 23
+ Width = 967
+ Align = alClient
+ TabOrder = 1
+ OnBrowserClosed = LazarusBrowserWindow1BrowserClosed
+ end
+end
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/uBrowserWindowDom.pas b/demos/Lazarus_any_OS/BrowserWindowDom/uBrowserWindowDom.pas
new file mode 100644
index 00000000..8dd1e314
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/uBrowserWindowDom.pas
@@ -0,0 +1,258 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+unit uBrowserWindowDom;
+
+{$mode objfpc}{$H+}
+{$I cef.inc}
+
+interface
+
+uses
+ GlobalCefApplication,
+ uCEFLazarusCocoa, // required for Cocoa
+ SysUtils, Messages, Forms, Controls,
+ Dialogs, ExtCtrls, StdCtrls, LMessages, Menus,
+ uCEFTypes, uCEFInterfaces, uHelperProcessDom,
+ uCEFWorkScheduler, uCEFLazarusBrowserWindow, uCEFProcessMessage, Classes;
+
+type
+
+ { TForm1 }
+
+ TForm1 = class(TForm)
+ AddressEdt: TComboBox;
+ GoBtn: TButton;
+ AddressPnl: TPanel;
+ LazarusBrowserWindow1: TLazarusBrowserWindow;
+ mDomHere: TMenuItem;
+
+ procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
+ procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
+ procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
+ procedure FormCreate(Sender: TObject);
+
+ procedure GoBtnClick(Sender: TObject);
+ procedure LazarusBrowserWindow1BrowserClosed(Sender: TObject);
+ private
+ FContextXY: TPoint;
+
+ procedure DoBeforeContextMenu(Sender: TObject; const browser: ICefBrowser;
+ const frame: ICefFrame; const params: ICefContextMenuParams;
+ const model: ICefMenuModel);
+ procedure DoCaptureMenuXY;
+ procedure DoContextMenuCmd(Sender: TObject; const browser: ICefBrowser;
+ const frame: ICefFrame; const params: ICefContextMenuParams;
+ commandId: Integer; eventFlags: TCefEventFlags; out Result: Boolean);
+ procedure DoProcessMessageReceived(Sender: TObject;
+ const browser: ICefBrowser; const frame: ICefFrame;
+ sourceProcess: TCefProcessId; const message: ICefProcessMessage; out
+ Result: Boolean);
+ protected
+ {$IFDEF WINDOWS}
+ procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
+ procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
+ {$ENDIF}
+
+ public
+
+ end;
+
+var
+ Form1: TForm1;
+
+
+implementation
+
+{$R *.lfm}
+
+// This is a demo with the simplest web browser you can build using CEF4Delphi and
+// it doesn't show any sign of progress like other web browsers do.
+
+// Remember that it may take a few seconds to load if Windows update, your antivirus or
+// any other windows service is using your hard drive.
+
+// Depending on your internet connection it may take longer than expected.
+
+// Please check that your firewall or antivirus are not blocking this application
+// or the domain "google.com". If you don't live in the US, you'll be redirected to
+// another domain which will take a little time too.
+
+// This demo uses a TChromium and a TCEFLinkedWindowParent
+
+// We need to use TCEFLinkedWindowParent in Linux to update the browser
+// visibility and size automatically.
+
+// Destruction steps
+// =================
+// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
+// 2. TChromium.OnClose sets aAction to cbaClose to destroy the browser, which triggers the TChromium.OnBeforeClose event.
+// 3. TChromium.OnBeforeClose sets FCanClose := True and sends CEF_BEFORECLOSE to close the form.
+
+uses
+ uCEFApplication;
+
+{ TForm1 }
+
+procedure TForm1.GoBtnClick(Sender: TObject);
+begin
+ LazarusBrowserWindow1.LoadURL(UTF8Decode(AddressEdt.Text));
+end;
+
+procedure TForm1.LazarusBrowserWindow1BrowserClosed(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TForm1.DoBeforeContextMenu(Sender: TObject;
+ const browser: ICefBrowser; const frame: ICefFrame;
+ const params: ICefContextMenuParams; const model: ICefMenuModel);
+begin
+ model.Clear;
+ model.AddItem(1, 'Get DOM');
+ TThread.Synchronize(nil, @DoCaptureMenuXY);
+end;
+
+procedure TForm1.DoCaptureMenuXY;
+begin
+ FContextXY := LazarusBrowserWindow1.ScreenToClient(Mouse.CursorPos);
+end;
+
+procedure TForm1.DoContextMenuCmd(Sender: TObject; const browser: ICefBrowser;
+ const frame: ICefFrame; const params: ICefContextMenuParams;
+ commandId: Integer; eventFlags: TCefEventFlags; out Result: Boolean);
+var
+ TempMsg : ICefProcessMessage;
+begin
+ if commandId = 1 then
+ begin
+ TempMsg := TCefProcessMessageRef.New(MSG_REQUEST_DOM); // Same name than TCefCustomRenderProcessHandler.MessageName
+ TempMsg.ArgumentList.SetInt(0, FContextXY.X);
+ TempMsg.ArgumentList.SetInt(1, FContextXY.Y);
+ LazarusBrowserWindow1.Chromium.SendProcessMessage(PID_RENDERER, TempMsg);
+ end;
+end;
+
+procedure TForm1.DoProcessMessageReceived(Sender: TObject;
+ const browser: ICefBrowser; const frame: ICefFrame;
+ sourceProcess: TCefProcessId; const message: ICefProcessMessage; out
+ Result: Boolean);
+begin
+ Result := False;
+ case message.Name of
+ MSG_RESPONSE_DOM: begin
+ Caption := message.ArgumentList.GetString(0);
+ Result := True;
+ end;
+ end;
+end;
+
+{$IFDEF WINDOWS}
+procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage);
+begin
+ inherited;
+
+ if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True;
+end;
+
+procedure TForm1.WMExitMenuLoop(var aMessage: TMessage);
+begin
+ inherited;
+
+ if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False;
+end;
+{$ENDIF}
+
+procedure TForm1.Chromium1BeforePopup(Sender: TObject;
+ const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
+ targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
+ userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
+ var windowInfo: TCefWindowInfo; var client: ICefClient;
+ var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue;
+ var noJavascriptAccess: Boolean; var Result: Boolean);
+begin
+ // For simplicity, this demo blocks all popup windows and new tabs
+ Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
+end;
+
+procedure TForm1.Chromium1OpenUrlFromTab(Sender: TObject;
+ const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring;
+ targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out
+ Result: Boolean);
+begin
+ // For simplicity, this demo blocks all popup windows and new tabs
+ Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
+end;
+
+procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
+begin
+ LazarusBrowserWindow1.CloseBrowser(True);
+
+ CanClose := LazarusBrowserWindow1.IsClosed;
+end;
+
+procedure TForm1.FormCreate(Sender: TObject);
+begin
+ LazarusBrowserWindow1.Chromium.OnBeforeContextMenu := @DoBeforeContextMenu;
+ LazarusBrowserWindow1.Chromium.OnContextMenuCommand := @DoContextMenuCmd;
+ LazarusBrowserWindow1.Chromium.OnProcessMessageReceived := @DoProcessMessageReceived;
+
+ LazarusBrowserWindow1.LoadURL(UTF8Decode(AddressEdt.Text));
+end;
+
+initialization
+ {$IFDEF DARWIN} // $IFDEF MACOSX
+ AddCrDelegate;
+ {$ENDIF}
+ if GlobalCEFApp = nil then begin
+ CreateGlobalCEFApp;
+ if not GlobalCEFApp.StartMainProcess then begin
+ DestroyGlobalCEFApp;
+ DestroyGlobalCEFWorkScheduler;
+ halt(0); // exit the subprocess
+ end;
+ end;
+
+finalization
+ (* Destroy from this unit, which is used after "Interfaces". So this happens before the Application object is destroyed *)
+ if GlobalCEFWorkScheduler <> nil then
+ GlobalCEFWorkScheduler.StopScheduler;
+ DestroyGlobalCEFApp;
+ DestroyGlobalCEFWorkScheduler;
+
+end.
+
diff --git a/demos/Lazarus_any_OS/BrowserWindowDom/uHelperProcessDom.pas b/demos/Lazarus_any_OS/BrowserWindowDom/uHelperProcessDom.pas
new file mode 100644
index 00000000..0583260c
--- /dev/null
+++ b/demos/Lazarus_any_OS/BrowserWindowDom/uHelperProcessDom.pas
@@ -0,0 +1,161 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * Web site : http://www.progdigy.com
+ * Repository : http://code.google.com/p/delphichromiumembedded/
+ * Group : http://groups.google.com/group/delphichromiumembedded
+ *
+ * Embarcadero Technologies, Inc is not permitted to use or redistribute
+ * this source code without explicit permission.
+ *
+ *)
+
+unit uHelperProcessDom;
+
+(* The code in this unit is executed in the renderer sub-process
+*)
+
+{$mode ObjFPC}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, uCEFApplication, uCEFInterfaces, uCEFDomVisitor, uCEFTypes,
+ uCEFProcessMessage;
+
+const
+ MSG_REQUEST_DOM = 'MSG_REQUEST_DOM';
+ MSG_RESPONSE_DOM = 'MSG_RESPONSE_DOM';
+
+procedure InitProcessMessagesHandler;
+
+implementation
+
+type
+
+ { TDomVisitorFindXY }
+
+ TDomVisitorFindXY = class(TCefDomVisitorOwn)
+ protected
+ FFrame : ICefFrame;
+ FX, FY: Integer;
+ procedure visit(const document: ICefDomDocument); override;
+ public
+ constructor Create(AFrame: ICefFrame; X,Y: Integer); reintroduce; virtual;
+ end;
+
+
+{ TDomVisitorFindXY }
+
+procedure TDomVisitorFindXY.visit(const document: ICefDomDocument);
+var
+ node, foundNode: ICefDomNode;
+ nb: TCefRect;
+ TempMsg : ICefProcessMessage;
+begin
+ node := document.GetBody;
+ foundNode := nil;
+ if node <> nil then
+ begin
+ nb := node.GetElementBounds;
+ if (FX >= nb.x) and (FX < nb.x + nb.width) and
+ (FY >= nb.y) and (FY < nb.y + nb.height)
+ then
+ begin
+ while node <> nil do
+ begin
+ foundNode := node;
+ if node.HasChildren then
+ begin
+ node := node.FirstChild;
+ while node <> nil do
+ begin
+ nb := node.GetElementBounds;
+ if (FX >= nb.x) and (FX < nb.x + nb.width) and
+ (FY >= nb.y) and (FY < nb.y + nb.height)
+ then
+ break // go outer loop
+ else
+ node := node.NextSibling;
+ end;
+ end
+ else
+ node := nil;
+ end;
+ end;
+ end;
+
+ TempMsg := TCefProcessMessageRef.New(MSG_RESPONSE_DOM); // Same name than TCefCustomRenderProcessHandler.MessageName
+ if foundNode <> nil then
+ TempMsg.ArgumentList.SetString(0, foundNode.AsMarkup)
+ else
+ TempMsg.ArgumentList.SetString(0, 'Not Found');
+ if (FFrame <> nil) and FFrame.IsValid then
+ FFrame.SendProcessMessage(PID_BROWSER, TempMsg);
+end;
+
+constructor TDomVisitorFindXY.Create(AFrame: ICefFrame; X, Y: Integer);
+begin
+ FFrame := AFrame;
+ FX := X;
+ FY := Y;
+ inherited Create;
+end;
+
+
+procedure DoProcessMessageReceived(const browser: ICefBrowser;
+ const frame: ICefFrame; sourceProcess: TCefProcessId;
+ const message: ICefProcessMessage; var aHandled: boolean);
+var
+ TempVisitor : TDomVisitorFindXY;
+begin
+ aHandled := False;
+ case message.Name of
+ MSG_REQUEST_DOM: begin
+ if (frame <> nil) and frame.IsValid then
+ begin
+ TempVisitor := TDomVisitorFindXY.Create(
+ frame,
+ message.ArgumentList.GetInt(0),
+ message.ArgumentList.GetInt(1)
+ );
+ frame.VisitDom(TempVisitor);
+ end;
+ aHandled := True;
+
+ end;
+ end;
+end;
+
+procedure InitProcessMessagesHandler;
+begin
+ GlobalCEFApp.OnProcessMessageReceived := @DoProcessMessageReceived;
+end;
+
+end.
+