Commit graph

75346 commits

Author SHA1 Message Date
Vadim Zeitlin
4816448cff Assume release CEF build by default under Unix
This prevents wxWebViewChromium from referencing debug-only functions
that are not defined in the release build of libcef_dll_wrapper.

Unfortunately, CEF build doesn't provide any way to detect if the
wrappers were built in debug or in release mode, so just assume the
latter and add --enable-cef-debug configure option to build with a debug
build of CEF wrapper if necessary.
2023-09-19 00:36:07 +02:00
Vadim Zeitlin
b5e278c0eb Link CEF files into webview sample build directory under Unix
Ensure that the sample can run using wxWebViewChromium backend out of
the box by setting things up so that it can find the CEF files. Note
that we use symlinks instead of actually copying these files, to avoid
wasting so much disk space (CEF libraries take more than 1GiB).
2023-09-15 01:56:08 +02:00
Vadim Zeitlin
ae8619b6dd Don't build separate webview_chromium library
Just include wxWebViewChromium in the webview library if it's enabled
during the build.

There doesn't seem to be any reason to build a separate library for it,
it's not really different from the other disabled by default wxWebView
backend (Edge).

And now that we don't need to link with an extra library, there is also
no need to have a separate webview_chromium sample, so just add a
possibility to run webview sample itself using Chromium backend by
setting WX_WEBVIEW_BACKEND environment variable.
2023-09-15 01:56:08 +02:00
Vadim Zeitlin
168ca9403d Return version information for wxWebViewChromium
This can be useful for diagnostic purposes and looks better than "0.0"
in the webview sample.

Notice that currently we return the compile-time version and not the
run-time version that could be retrieved using cef_version_info()
because this is simpler and we shouldn't be ever using a different
version from the one we were compiled with anyhow.
2023-09-14 19:20:11 +02:00
Vadim Zeitlin
05a8dfa555 Implement availability check for wxWebviewChromium under GTK
Return false when using Wayland as the backend creation can only fail in
this case.
2023-09-14 19:19:59 +02:00
Vadim Zeitlin
9c30f459f8 Use "override" in wxWebViewFactoryChromium
No real changes, just ensure that we really override the base class
virtual functions.
2023-09-14 19:18:43 +02:00
Vadim Zeitlin
b788711ca1 Move wxWebViewFactoryChromium to the source file from the header
There doesn't seem to be any need for this class to be public.

No real changes.
2023-09-14 19:18:32 +02:00
Vadim Zeitlin
ad69f3779a Remove "adv" library from webview sample
This library doesn't contain anything any more and exists only for
compatibility, so don't reference it.
2023-09-13 21:27:06 +02:00
Vadim Zeitlin
118ca49284 Improve reporting of enabled wxWebView backends in configure
Don't report "IE" backend as being enabled just because it's enabled by
default under MSW.

Also give a warning if any of MSW-specific backends is enabled when not
building wxMSW.
2023-09-13 21:26:42 +02:00
Vadim Zeitlin
2ef44570fd Work around bug with out of order JS execution results
Modify the sample to show the correct value of the user agent when using
WebKit backend as this got broken by calling it inside an event handler
executed later but before the idle event handler could dispatch the
result of JS executed from inside WebKit AddScriptMessageHandler()
implementation, resulting in misinterpreting this result ("{}") as the
user agent string.

The real fix is, of course, to deal with the JS execution results coming
out of order in some way.
2023-09-08 01:51:47 +02:00
Vadim Zeitlin
c109f7f593 Implement SetProxy() in wxWebViewChromium too
Update the documentation to mention that it supports it and add an
example showing how to call this function.
2023-09-08 01:34:59 +02:00
Vadim Zeitlin
80ce14910c Initialize wxWebViewChromium members in their declarations
No real changes, but ensure that all of them are always initialized.
2023-09-08 01:34:59 +02:00
Vadim Zeitlin
81283f84dd Merge branch 'master' into webview-chromium-new
This pulls in wxWebView::SetProxy() addition.
2023-09-08 01:34:21 +02:00
Vadim Zeitlin
49b2f9c809 Merge branch 'webview-proxy'
Add wxWebView::SetProxy().

See #23854.
2023-09-08 01:31:04 +02:00
Hartwig Wiesmann
879cc1e574 Fix file history items formatting when loading them from config
Add DoRefreshLabels() to wxFileHistoryBase::Load() to ensure that the
paths are formatted correctly.

Closes #23799.

See #23857.
2023-09-08 01:24:41 +02:00
Vadim Zeitlin
ff5c972b7f Set proxy to the environment variable value for all backends
Don't do it just for Edge one, as WebKit-based one supports it too and
the example code is nicer without the extra checks.
2023-09-07 15:33:39 +02:00
Vadim Zeitlin
0fd6cf99a3 Implement wxWebView::SetProxy() for Edge backend
Currently it can only be called before Create() because it has to be
passed via the additional browser arguments and can't be changed later.
2023-09-07 15:33:39 +02:00
Vadim Zeitlin
7c5d30fb32 Add wxWebView::SetProxy() and implement it for WebKit2 backend
Update the sample to allow specifying the proxy in it.
2023-09-07 15:33:39 +02:00
Vadim Zeitlin
a10ae82250 De TAB-ify Info.plist files
There doesn't seem to be any reason to use hard TABs in them, so don't.

No real changes.
2023-09-06 18:54:32 +02:00
Vadim Zeitlin
285b75bcd4 Remove extra whitespace documentation 2023-09-06 18:52:43 +02:00
Vadim Zeitlin
61bc16fa25 Update CEF-related build instructions
Moslty document that 5 helper applications are now needed under Mac and
not just a single one.
2023-09-06 18:49:57 +02:00
Vadim Zeitlin
9966bfd052 Don't bother setting the cache directory for Chromium
It defaults to $root_cache_path/Cache which is fine and our existing
attempt to set it didn't work (and resulted in an error message) anyhow
as it must be under $root_cache_path now.
2023-09-06 18:30:59 +02:00
Vadim Zeitlin
06c62f9aa4 Create all macOS helper apps required by current CEF version
For some reason we need 5 of them instead of just one now.

At least save some space by using links instead of duplicating the same
file 5 times.
2023-09-06 18:21:29 +02:00
Vadim Zeitlin
4130f7fa67 Add tracing to URL loading functions
No real changes, just make the trace logs more useful.
2023-09-06 18:21:29 +02:00
Vadim Zeitlin
9f11557717 Adjust makefiles to the new CEF framework install name
It is now defined as

@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework

in the framework itself, which means that we don't need to change it at
all for the main application and the wx library it uses.

We still need to change it for the helper application, but the command
doing it must be adjusted.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
7231a2d771 Fix parallel build of webview_chromium_helper under Mac
Make fix_cef_link target depend on webview_chromium_helper itself,
otherwise it could try to copy this file before it was created.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
784121a07a Remove apparently accidental condition in webview sample bakefile
"target" doesn't seem to make sense nor be needed here, as removing it
doesn't change anything in the generated files.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
9f2fce3859 Ensure that libcef.so is loaded first in webview sample
Use --no-as-needed linker flag to make this happen as otherwise it is
still loaded after libc.so (unless LD_PRELOAD is used).
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
c0c345a816 Check that calling CefInitialize() won't hang under Linux
Verify that libcef.so was loaded before libc.so as otherwise calling
CefInitialize() would currently hang the program, see the discussion at
https://magpcss.org/ceforum/viewtopic.php?t=15118
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
68c2a2b96f Also add checks that CefBrowser itself is valid
Further extend the changes of the previous two commits and cover all the
functions using the possibly not yet initialized browser object.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
8d5bd418ae Add GetHost() helper and check its validity too
This is similar to the previous commit and is done for the same reasons,
but adds checks verifying that CefBrowserHost is valid before using it.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
09214df74c Add GetMainFrame() helper and check that it's valid
Avoid crashes if some functions are called before the browser is fully
initialized -- this is relatively likely to happen as the existing code
may not wait for wxEVT_WEBVIEW_CREATED before calling them, as must be
done with wxWebViewChromium.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
92f6f164b3 Add wxEVT_WEBVIEW_CREATED for wxWebViewChromium async creation
wxWebViewChromium creation is asynchronous and the object can't be
really used until OnAfterCreated() is called, so expose this in the
public API via a new event sent when the object becomes actually usable.

As a side effect, add a convenient wxWebViewEvent ctor taking wxWebView
as argument and calling SetEventObject() itself, instead of forcing all
code creating wxWebViewEvents to do it.
2023-09-06 03:50:34 +02:00
Vadim Zeitlin
f1734a29b6 Use compiler-generated wxWebViewEvent default ctor
No real changes, just let the compiler do what it does best and generate
the code for us instead of writing "{}" explicitly.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
704e5f1419 Improve CEF detection in configure
Check for the libraries too and not just for headers.

Also cache the result of the check.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
08d6fe059b Update CEF requirements for the current version
Also don't use "CEF3" any more as "CEF1" doesn't really exist by now any
longer and there is only a single version of CEF.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
b4380b5f9e Use C++14 by default in configure when using CEF
Don't default to C++11 as CEF headers are not compatible with it, so
configure would succeed but the build would then fail.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
7aec5a7e62 Implement browser window resizing correctly under Mac too
While the window was somehow resized on its own under Mac (and only
there) after the initial creation, it didn't have the correct size
initially if we didn't give it to it, so provide a Mac-specific
implementation of wxEVT_SIZE handler too, which fixes this and allows to
remove an ugly Mac-specific workaround from the sample.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
0dffac1829 Add private header for wxWebViewChromium Mac-specific functions
Instead of just declaring the function inline in the common code, do it
in a header included from both common C++ and Mac Objective C++ sources.

No real changes.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
88b0a10f73 Avoid potential crash on shutdown under Mac
We can't wait for OnBeforeClose() to be called in the dtor there, or,
IOW, we can't count on it being called before the object is destroyed
and hence we can't update the flag in it neither.

Don't do it and just hope that the ClientHandler object always gets
destroyed soon after wxWebViewChromium itself anyhow because it's only
referenced by an autorelease pool.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
478975695f Fix compilation of CefAppProtocol-patching code
It's not clear if this really should be doing something as previously
existing code definitely didn't, but it seems like actually storing the
flag should be no worse and at least now it compiles (due to the added
casts to IMP).
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
db255db61c Use C++11 nullptr in CEF helper process in the sample
This fixes its compilation under Mac and also avoids triggering the
check forbidding the use of NULL in the new code.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
dfe4fc858f Add x64 support and improve wxWebViewChromium sample MSVS project
Use variables defined in our .props files instead of hard-coded values
and use DPI aware manifest instead of using "compatibility" one with
which the sample didn't work correctly in high DPI.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
6b04c6ca49 Add CEF includes to x64 configs in wxWebViewChromium MSVS project
This was only done for Win32 configurations before.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
4395a47d40 Remove redundant wxWebViewChromium forward declaration
There is no need to do it just before the full class declaration.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
013940da8f Move ClientHandler to wxCEF namespace
Use "wxCEF" prefix for this class to avoid any conflicts by using
non-wx-prefixed name.

Also replace wxWebViewChromiumImplData with wxCEF::ImplData as this is
shorter and more consistent with ClientHandler.

Finally stop using anonymous namespace for wxBrowserProcessHandler and
wxCefApp, as we can now put them into the same wxCEF namespace.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
e5e727747b Improve waiting for browser close to avoid crash on shutdown
Ensure that CefLifeSpanHandler::OnBeforeClose() is called before
returning from wxWebViewChromium dtor, as otherwise we may try to shut
down CEF before the browser object is destroyed.

Under MSW it's enough to destroy the window ourselves to make this
happen, but under GTK/X11 we need to manually pump the messages, as
OnBeforeClose() is only called when the X event notifying about the
actual window destruction arrives.

Also make the code cleaner by using flags in wxWebViewChromiumImplData
instead of reusing m_clientHandler pointer to indicate that DoClose()
was called.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
ed131c9364 Improve work scheduling logic
Restart the timer if it's already running but its expiration time is
beyond the specified delay, otherwise we could be waiting for too long.

This commit is best viewed ignoring whitespace-only changes.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
dc92de0c3a Don't bother using DeferWindowPos() for resizing one window
This doesn't seem to be necessary, just call SetWindowPos() instead,
this is simpler and has the same effect.

No real changes.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
7dc4abd99f Add ClientHandler::GetWindowHandle() helper
No real changes, just move the code from wxWebViewChromium::OnSize() to
a reusable function.
2023-09-06 03:50:05 +02:00