Commit Graph
124 Commits
Author SHA1 Message Date
Blake-Madden e871f1a841 Add wxWebView::PrintToPDF()
Add a possibility to save the page as PDF, possibly with some
non-default print settings.

Closes #26583.
2026-06-21 18:51:38 +02:00
Blake-Madden 82f3989c82 Add new Print function to WebView that takes printer settings
Implement it for Edge, GTK and macOS backends and simply fall through to
Print() without parameters for the other ones.

Closes #26239.
2026-03-13 15:39:54 +01:00
Maarten Bent ccbd0ad63a Move wxWebViewBackendChromium name into common webview header
This allows to check for Chromium back-end availability without needing
wxUSE_WEBVIEW_CHROMIUM guards.

Closes #25911.
2025-10-25 15:10:07 +02:00
PB d5c140a801 Fix webrequest and webview samples build with MSVC in C++20 mode
Unix builds / Ubuntu 24.04 wxGTK with ASAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 compatible 3.0 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK UTF-8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxQt (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxX11 (push) Has been cancelled
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Has been cancelled
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK with UBSAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxDFB (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 static with gcc 4.8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 2 (push) Has been cancelled
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Has been cancelled
CMake builds / Windows MSVC (push) Has been cancelled
CMake builds / macOS latest wxOSX Ninja (push) Has been cancelled
CMake builds / macOS 14 wxOSX Xcode (push) Has been cancelled
CMake builds / macOS 14 wxIOS (push) Has been cancelled
CMake builds / Windows wxQt 6.8 (push) Has been cancelled
Mac builds / wxMac Universal C++14 (push) Has been cancelled
Mac builds / wxMac ARM with ASAN (push) Has been cancelled
Mac builds / wxiOS (push) Has been cancelled
Mac builds / wxMac Intel C++17 (push) Has been cancelled
Mac Xcode builds / iOS Simulator static (push) Has been cancelled
Mac Xcode builds / macOS dynamic Release (push) Has been cancelled
Mac Xcode builds / iOS static Debug (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Has been cancelled
MSW builds / wxMSW vs2019 DLL Release x64 (push) Has been cancelled
MSW builds / wxMSW vs2019 Debug Win32 (push) Has been cancelled
MSW builds / wxMSW vs2022 Release arm64 (push) Has been cancelled
MSW builds / msw-msys2-clang (push) Has been cancelled
MSW cross-builds / wxMSW 64 bits (push) Has been cancelled
MSW cross-builds / wxMSW/Univ (push) Has been cancelled
MSW cross-builds / wxMSW 32 bits (push) Has been cancelled
Code Checks / Check Spelling (push) Has been cancelled
Code Checks / Check Whitespace (push) Has been cancelled
Code Checks / Check Mixed EOL (push) Has been cancelled
Code Checks / Check C++ Style (push) Has been cancelled
Code Checks / Check All Headers In allheaders.h (push) Has been cancelled
Update Documentation / Update Online Documentation (push) Has been cancelled
No Response / no-response (push) Has been cancelled
Using a const char* and a wxString in the two branches of the ternary
operator resulted in compile-time errors when using C++20 standard
since the result type of the conditional expression was ambiguous,
so add explicit conversions to fix it.

See also #19355.

Closes #25501.
2025-06-09 22:57:00 +02:00
Vadim Zeitlin 74a1498eee Remove unnecessary use of wxLogXXX("%s")
Just pass the strings directly to wxLogXXX functions as this works
correctly after the changes of the parent commit.
2025-05-17 22:44:48 +02:00
Tobias Taschner f982139ffc Add support for clearing browsing data in wxWebView 2024-12-23 00:28:46 +01:00
Lauri Nurmi 87c1aae252 Fix double negatives used with 'neither'
Replace most 'neither' words introduced after 2b0ee48ef7
(Fix double negatives used with 'neither', 2023-11-25)
with 'either'.

All changes are to comments only.

Closes #24999.
2024-12-11 17:57:46 +01:00
Vadim Zeitlin fa23c93832 Merge branch 'webview-cef-devtools'
Implement dev tools support for wxWebViewChromium.

See #24799.
2024-09-15 18:59:30 +02:00
Vadim Zeitlin 9cc48d7ec1 Merge branch 'webview-version'
Add possibility to retrieve both build- and run-time wxWebView version

See #24778.
2024-09-15 18:58:57 +02:00
Vadim Zeitlin 2e6d79acf2 Add wxWebView::ShowDevTools()
Implement it for Edge, WebKit2GTK and Chrome backends.

It doesn't seem possible to implement this for WebKit macOS backend and
IE backend doesn't support dev tools at all.

Also note that Edge backend doesn't seem to support closing the dev
tools window, so don't provide this functionality for now, even if it
could be implemented for WebKit2 and Chrome backends.
2024-09-05 22:09:57 +02:00
Vadim Zeitlin 28d3cbdfb9 Remove DebugOnlyLog and fix memory leak in webview sample
DebugOnlyLog is not needed any more since 33931b7378 (UI improvements to
WebView sample, 2024-03-19) replaced wxLogWindow, which doesn't let
trace messages through (but probably should?), with wxLogTextCtrl, which
doesn't eat the trace messages.

Also fix a memory leak introduced in the same commit: the old logger
returned by SetActiveTarget() must be destroyed.

See #24417.

Closes #24787.
2024-09-05 18:53:18 +02:00
Vadim Zeitlin 435fa14076 Add possibility to retrieve compile-time wxWebView version
This is currently only implemented for GTK WebKit2 and CEF backends.

Show both the compile- and run-time versions in the sample.
2024-08-23 00:19:53 +02:00
Vadim Zeitlin cf22fbb87f Show wxWebView backend version even if it has description too
For the backends that had a description string (such as Chromium), we
showed only it but not the actual version, which was a bit confusing, so
show both the version and the description, even if the latter includes
the former too.
2024-08-23 00:04:26 +02:00
Vadim Zeitlin 9690779f90 Fix crash on webview sample startup when using CEF backend
Unfortunately the workaround in dce09c9b2a (Avoid crash on startup in
webvew sample under Wayland, 2024-04-22) broke the sample when using CEF
as we can't capture the local lambda by reference.

Fix this simply by making a copy of it instead -- this is not the most
efficient way to do it, but it doesn't really matter here and it's the
simplest one.
2024-06-15 20:37:41 +02:00
Vadim Zeitlin dce09c9b2a Avoid crash on startup in webvew sample under Wayland
The workaround for wxWebViewChromium added in f5e2af9a28 (Make
wxWebViewChromium work with wxGTK3 and X11, 2023-09-02) broke
wxWebViewWebKit under Wayland as calling wxYield() inside
wxEVT_WEBVIEW_CREATED handler results in

Error flushing display: Resource temporarily unavailable

error from GTK and immediate application exit.

This is almost certainly a GTK bug and should be fixed there, see
https://gitlab.gnome.org/GNOME/gtk/-/issues/124, but for now make the
workaround even uglier to avoid it.
2024-04-22 17:47:02 +02:00
Vadim Zeitlin 4fe947b2ba Fix defining WX_WEBVIEW_BACKEND as "cef" for the webview sample
The direction of comparison was accidentally reversed.
2024-03-31 19:43:36 +02:00
Tobias Taschner 33931b7378 UI improvements to WebView sample
- Enlarge the main window to make menu button more easily accessible.
- Show logs in a text control instead of a separate window.

Closes #24417.
2024-03-19 16:48:54 +01:00
Vadim Zeitlin bbddaa2983 Use flags instead of multiple booleans in webview sample
No real changes, just avoid having to write "false, nullptr, true" in
the function call and use the much more clear "WebFrame::Private"
instead.
2024-03-16 01:23:13 +01:00
Tobias Taschner 72397e14a2 Add EnablePersistentStorage method to wxWebView 2024-03-15 22:04:32 +01:00
Vadim Zeitlin 9c33be4f5e Use a helper lambda for naming history menu items
Shorten the code a bit more.

No real changes.
2024-02-02 18:01:24 +01:00
Vadim Zeitlin 44bc26f087 Use range-for loops for iterating over wxWebViewHistoryItems
No real changes, just simplify the code a bit.
2024-02-02 17:59:01 +01:00
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