Commit graph

103 commits

Author SHA1 Message Date
Scott Talbert
3ef1aee986 Fix WebView sample when there are blank title pages in history
Otherwise, the wxMenu code asserts due to an empty item.
2024-02-01 20:56:36 -05:00
Vadim Zeitlin
83d69a1cd9 Revert "Add debug postfix to libcef_dll_wrapper"
This reverts commit 3d51977acf because
it's incompatible with the library names created by CMake when building
CEF directly, and not via wx CMake files.
2024-01-06 03:20:50 +01:00
Maarten Bent
3d51977acf
Add debug postfix to libcef_dll_wrapper 2023-12-24 18:06:14 +01: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
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
81283f84dd Merge branch 'master' into webview-chromium-new
This pulls in wxWebView::SetProxy() addition.
2023-09-08 01:34:21 +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
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
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
f5e2af9a28 Make wxWebViewChromium work with wxGTK3 and X11
Make browser creation actually work by postponing it until the host
window is realized and so has a valid X11 Window.

Remove unnecessary code manually creating GTK widget and just use the
standard wxGTK wxWindow instead.

Add code for setting the visual compatible with CEF to avoid X11 errors,
see https://github.com/chromiumembedded/cef/issues/3564, with many
thanks to Jiří Janoušek for finding and solving this problem originally.

Adjust the sample to handle wxWebView::Create() failure (not very
gracefully, but still better than just crashing) and to avoid using it
until it is fully created.

Update documentation to mention GTK limitations.
2023-09-06 03:50:05 +02:00
Vadim Zeitlin
18456e7de2 Add tracing messages to wxWebViewChromium code
Log calls to some callbacks using "cef" trace mask.

To make these messages actually visible in the sample, use a log target
showing only debug messages and pass messages through to it from
wxLogWindow.
2023-09-01 21:18:17 +02:00
Vadim Zeitlin
b6bfdd97c9 Merge branch 'master' into webview-chromium
Update to the latest master.
2023-08-30 02:03:00 +02:00
Darrell Wright
13aa094ea6 Fix crash in "View text" dialog of the webview sample
Set the sizer on the dialog and not the main frame itself.

Closes #23830.
2023-08-28 02:14:00 +02:00
Vadim Zeitlin
8f4c9f41a4 Use std::map<> instead of wxHashMap in webview sample
No real changes, just use the standard class.
2023-04-24 22:47:18 +01:00
Tobias Taschner
e15a1ac18e
Add wxWebViewWindowFeatures and event
This replaces the previously implemented wxWebViewWindowInfo.

It explicitly breaks the previous API to enable WebKitGTK
integration and to make the usage in application code less error prone.

A new event wxEVT_WEBVIEW_NEWWINDOW_FEATURES is added to allow
access to the window features and the child web view.
2023-03-24 15:10:21 +01:00
Tobias Taschner
01ee3942f8
Add wxWebView child window handling
Add new class wxWebViewWindowInfo:
This new class returned by wxWebViewEvent::GetTargetWindowInfo() allows
to get information about the window that is about to be opened and to
set the window that will be used to display the content.
2023-03-09 14:30:19 +01:00
Tobias Taschner
45d5de6a26
Add wxEVT_WEBVIEW_WINDOW_CLOSE_REQUESTED
This event is usually triggered by javascript calling window.close()
2023-03-09 14:29:25 +01:00
Tobias Taschner
be10ce0713 Add wxWebViewEvent::IsTargetMainFrame()
Allows to determine if a navigation is happening in the main frame
or an embedded iframe when handling wxEVT_WEBVIEW_NAVIGATING.

Additionally implement previously missing wxEVT_WEBVIEW_NAVIGATING
events for frames with the Edge backend.

See #23238.
2023-02-08 17:42:06 +01:00
Tobias Taschner
db9419af4b
Add wxWebView::EnableBrowserAcceleratorKeys()
The edge backend has various accelerator keys enable per default.
This include Ctrl-P, Ctrl-F, F5 and others. In many uses of webview
this might not be desirable and can be disabled.

This is currently only implemented for the Edge backend.

Raises required WebView2 SDK version from 1.0.705.50 to 1.0.864.35
2022-12-23 14:12:36 +01:00
Vadim Zeitlin
4f4c5fcfdf Use nullptr instead of NULL in the code and documentation
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.

Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.

And also use null in the assert messages.

Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
2022-10-18 01:25:25 +02:00
PB
88d526660f Replace wxOVERRIDE and wxNOEXCEPT with override and noexcept
Don't use deprecated macros in wxWidgets itself.
2022-10-15 18:10:45 +02:00
Tobias Taschner
0adf31169d
Add advanced handler to webview sample
Demonstrate how to implement and use wxWebViewHandler::StartRequest()
2022-09-16 21:00:52 +02:00
Tobias Taschner
73d37d460d
Add tango art for refresh and stop
Use the added art IDs in webview sample
2022-02-01 09:50:32 +01:00
Vadim Zeitlin
2208f53ba3 Add wxART_WX_LOGO and use it in the webview sample
Embed SVG data of the wx logo into the library itself to make it
available to all wx programs, including the samples. This is a bit
wasteful, but <12KiB is not really noticeable compared to the library
size.
2022-01-23 15:40:04 +01:00
PB
ccb6b10c1f Use SVG-based toolbar bitmaps in webview sample
In webview sample toolbar use wxBitmapBundles created from SVG files
instead of XPM bitmaps, as this results in much better appearance in
high DPI.

Closes #2642.
2022-01-17 01:07:57 +01:00
Tobias Taschner
a5cec42bb6 macOS: Use public API for fullscreen in wxWebView
To enable fullscreen support with WKWebView private API which was
available since macOS 10.11 was used. Beginning with macOS 12.1 this
resulted in unpredictable layout issues inside the webview.

This reimplementation using java script and message handlers does only
use public API. This also makes the fullscreen message more controlable
as the webview does no longer put the containing window in fullscreen
mode without application code intervention. That also unifies macOS with
the way Edge sends this event in MSW.

Closes https://github.com/wxWidgets/wxWidgets/pull/2629
2022-01-04 22:54:39 +01:00
Tobias Taschner
d31f1dc400
Add wxWebViewEvent::IsError() 2021-11-03 13:35:24 +01:00
Tobias Taschner
47833a6d24
Add RunScriptAsync() to webview sample 2021-11-03 11:19:09 +01:00
Vadim Zeitlin
f37d449208 Add convenient wxFileName::GetAbsolutePath() wrapper and use it
This wrapper simply combines the calls to MakeAbsolute() and
GetFullPath(), but using it results in shorter and more clear code, so
it seems to be worth having.
2021-07-11 14:51:31 +01:00
Tobias Taschner
97e469c255
Add access to user agent for wxWebView
Allow setting a custom user agent for a webview.
Also allow access to the current user agent.
2021-03-16 22:53:00 +01:00
Tobias Taschner
166d7e2c83
Fix unused warning in sample 2021-02-28 20:06:59 +01:00
Tobias Taschner
2a16638e2a
Fix EOL issues 2021-02-28 20:03:31 +01:00
Tobias Taschner
29bfcdfd5e
Add common web message identifier 2021-02-27 11:55:50 +01:00
Tobias Taschner
6f7ac6a934
Add wxWebView::AddUserScript()
This allows to inject javascript code across multiple pages
2021-02-26 23:41:39 +01:00
Tobias Taschner
140e9825b7
Log error if script handler cannot be added 2021-02-26 21:41:02 +01:00
Tobias Taschner
3f23273f46
Fix typo in sample 2021-02-26 16:59:57 +01:00
Tobias Taschner
c3d0d7d000
Identify script handler in message event 2021-02-26 16:59:56 +01:00
Tobias Taschner
c78147b267
Add script command handler to sample 2021-02-26 16:59:56 +01:00
Tobias Taschner
a7ff7a8012
Implement script message for WKWebView backend 2021-02-26 16:59:56 +01:00
Tobias Taschner
f6a23a0431
Add wxEVT_WEBVIEW_FULLSCREEN_CHANGED event
The event is triggered by wxWebView when the page requests fullscreen view.

It's currently only implemented for the edge backend.
2021-02-09 22:28:29 +01:00
Tobias Taschner
693d946ffc
DPI independent default size in WebView sample 2021-02-09 18:02:36 +01:00
Tobias Taschner
788bef2cf2
Select Edge as the default backend on MSW
If enabled and available at runtime use the Edge backend.
This is probably more useful for most users.
2021-02-05 22:18:29 +01:00
Tobias Taschner
0d82348328
Add wxWebView::GetBackendVersionInfo()
Allows to get the WebView backend version if available
Currently implemented for IE, Edge and webkit2.
2021-02-05 22:18:28 +01:00
Tobias Taschner
489afb3336
Allow using a fixed version with wxWebViewEdge
A fixed version may be distributed with the application
and wxWebViewEdge::MSWSetBrowserExecutableDir() allows
it's usage with wxWebViewEdge.
2021-02-05 22:18:28 +01:00
Tobias Taschner
4c35689b9d
Use two step creation for WKWebView on macOS 2020-12-14 10:18:13 +01:00
Tobias Taschner
bde4a45e9c
Remove assert in webview sample
Not all backends return IsBusy() during this callback
2020-12-14 10:18:13 +01:00
PB
f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00