Commit graph

48 commits

Author SHA1 Message Date
Vadim Zeitlin
30c8c64e45 Allow changing wxWebViewBackendChromium data directory path
Use the value provided via wxWebViewConfiguration::SetDataPath() if any.
2024-01-06 03:20:50 +01:00
Vadim Zeitlin
416e241e6a Add wxWebViewConfigurationImplChromium scaffolding
It is perfectly useless for now, but provides place to add more things
in the upcoming commits.
2024-01-06 03:20:50 +01:00
Vadim Zeitlin
8655d7bb95 Add wxEVT_WEBVIEW_CHROMIUM_MESSAGE_RECEIVED
This allows to handle IPC messages from custom JS functions in the code
using wxWebViewChromium.
2024-01-05 01:43:32 +01:00
Vadim Zeitlin
4f1a249b76 Call CefDoMessageLoopWork() even more aggressively
Calling this function from OnInternalIdle() is not always enough, so
call it before processing each and every event to ensure that CEF can
really do whatever it needs to be doing internally.

This doesn't seem to noticeably slow down the program and solves weird
problems, like embedded text boxes (e.g. search zones on the web sites)
not getting focus on click.
2023-12-22 02:20:49 +01:00
Vadim Zeitlin
6f130c121f Add wxWebViewChromium::SetRoot()
This allows to define a prefix for all the files used by the application
in the browser.
2023-12-20 01:39:02 +01:00
Vadim Zeitlin
e30309bf8c Replace wxEVT_IDLE handler with overridden OnInternalIdle()
This function is always called, even if the application prevents the
wxEVT_IDLE handler from being called, either by forgetting to Skip() the
event in its own handler of this message or by changing the global idle
event generation mode to wxIDLE_PROCESS_SPECIFIED.
2023-11-29 01:47:29 +01:00
Vadim Zeitlin
8d4ca2b191 Extract wxIdleEvent handler into its own function
No real changes yet, just make the lambda a member function before
adding more code to it.
2023-11-29 01:47:29 +01:00
Vadim Zeitlin
fada5fa044 Make wxWebViewChromium::OnSize() private
Also make a couple of cosmetic/style fixes.

No real changes, just don't leave the event handler public when it
doesn't have to be.
2023-11-29 01:47:29 +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
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
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
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
efe58535d1 Hide private wxWebViewChromium data into a private struct
No real changes, just a refactoring to make further changes simpler.
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
61cb46cbed Implement external message pump support in recommended way
Override OnScheduleMessagePumpWork() to schedule work to be done on the
main thread instead of relying on only doing this in wxEVT_IDLE handler.

Still keep the latter, however, as without it the window doesn't refresh
correctly -- which might indicate some other problem somewhere.

This also allows to remove an ugly loop calling CefDoMessageLoopWork()
10 times before shutting down CEF and, most importantly, avoids a fatal
assert with "Object reference incorrectly held at CefShutdown" error on
exit in debug builds.
2023-09-01 21:18:17 +02:00
Vadim Zeitlin
81fe0cb3be Implement wxWebViewChromium::{Get,Set}ZoomFactor()
Just use the corresponding CefBrowserHost methods.
2023-08-30 02:04:05 +02:00
Vadim Zeitlin
0a889ad38f Fix wxWebViewChromium::RunScript() signature
Make the function const, as it should be now.
2023-08-30 02:04:05 +02:00
Vadim Zeitlin
134cd72310 Use C++11 keywords in wxWebView CEF backend
Use "override" and "nullptr".
2023-08-30 02:04:05 +02:00
Tobias Taschner
6b03c0aea7
Remove tabs from webview chromium source files 2018-02-21 11:09:26 +01:00
Tobias Taschner
84efbe6255
Move CEF initialization from module and enable cache
By initializing CEF from the first Create() call data paths are available
and cache can be enabled. This would also allow for more settings
customization from user code in the future.
2018-02-20 20:34:00 +01:00
Tobias Taschner
f6269ca8a6
Handle CEF message loop from idle events
Handlign CEF messages on idle seems to work much better on macOS
2018-02-20 18:33:23 +01:00
Tobias Taschner
eca584e719
Integrate all CEF initialization and message loop work into implementation
Handle Startup and Shutdown of CEF in a wxModule and don't require the
user to implement a timer to handle the CEF work loop
2018-02-20 18:33:20 +01:00
Tobias Taschner
08434378d7
Mark overriden virtual methods with override
Also update signatures of two CEF overrides.
2018-02-20 18:33:19 +01:00
Tobias Taschner
276cb671b7
Remove CEF implementation details from header
By moving all CEF implementation details a client
does not require the CEF headers to use wxWebViewChromium
2018-02-20 18:33:16 +01:00
Tobias Taschner
82700ba90f
Remove support for CEF versions before 3000 2018-02-20 18:33:15 +01:00
Tobias Taschner
9e0020732c
Change wxWebViewChromium::RunScript to current API
Returning a value is currently not supported and will return false
2018-02-20 18:33:12 +01:00
Steven Lamerton
40f7908232
Update wxWebViewChromium copyright dates. 2018-02-20 18:33:07 +01:00
Steven Lamerton
5101c8ed66
Add support for CEF 2062. 2018-02-20 18:33:03 +01:00
Haojian Wu
e3069bf7ba
[Windows] Update to use the new webviewchromium library.
* Update VS2010 project file.
* Update webview_chromium sample VS2010 project file.
* Introduce a WXDLLIMPEXP_WEBVIEW_CHROMIUM and WXDLLIMPEXP_DATA_WEBVIEW_CHROMIUM
  macro to enable dynamic builds on windows.
2018-02-20 18:32:52 +01:00
Haojian Wu
87c9643748
Avoid compiler's warning of unused parameters. 2018-02-20 18:32:43 +01:00
Haojian Wu
5692bb8072
Add wxUSE_WEBVIEW_CHROMIUM macro check in webview_chromium.h/.cpp. 2018-02-20 18:32:08 +01:00
Haojian Wu
012567f6e1
Rename RunCEFMessageLoopOnIdle to DoCEFWork for better understanding. 2018-02-20 18:31:57 +01:00
Haojian Wu
b3478c4ed2
Nits: Correct code style. 2018-02-20 18:31:54 +01:00
Haojian Wu
aaaefbbecf
Add custom handler support. 2018-02-20 18:31:52 +01:00
Haojian Wu
0753802f49
Cleanup: remove StartUpSubprocess() since it no longer used. 2018-02-20 18:31:38 +01:00
Haojian Wu
5d3b9f7296
Use double quotes instead of angle brackets to include wx header files. 2018-02-20 18:31:37 +01:00
Haojian Wu
13db4d4a90
Cleanup: remove unused m_timer. 2018-02-20 18:31:33 +01:00
Haojian Wu
9061615ec6
Remove CEF message loop running to client.
Running CEF message loop inside wxWebviewChromium internal will get
segument fault, while moving to client doesn't.

Reset to the previous client solution to avoid segument falut, since I
don't figure out the segument fault reason.
2018-02-20 18:31:31 +01:00
Haojian Wu
d51a8d20f7
Set cef messageloop running inside wxWebviewChromium instead of client
side.
2018-02-20 18:31:27 +01:00
Haojian Wu
9eca39a928
Integrate CEF MessageLoop to wxWidgets MessageLoop.
* Enable webview_chromium on Linux, webview_chromium runs normally,
  but browser window is split out of wxWidget window now and we need to
  host it in wxWidgets window later.
* Make cef messageloop processing in wx::ProcessIdle period, this way
works on windows and linux.
* Don't use multiple_message_loop on Windows.
2018-02-20 18:31:24 +01:00
Haojian Wu
3a4d793579
Enable wxWebviewChromium dynamic builds. 2018-02-20 18:31:16 +01:00
Haojian Wu
0ffbd0741b
Nits: Fix code style. 2018-02-20 18:31:12 +01:00
Haojian Wu
7eb95d7475
Nits: fix code style. 2018-02-20 18:31:10 +01:00
Haojian Wu
cd7df9c28b
Send WEBVIEW_ERROR event after CEF finishing loading.
Currently, WEBVIEW_ERROR event is sent to client on CEF::OnLoadError(),
which may cause the error message of wxInfoBar disapear.

CEF::OnLoadEnd will be invoked after CEF::OnloadError, if WEBVIEW_ERROR
event get processed before CEF::LoadEnd, the wxInfoBar's message will
disappear since the webpage will get loaded in CEF::LoadEnd.

CEF will return "data:text/html,chromewebdata" when url is invalid.
2018-02-20 18:31:10 +01:00
Haojian Wu
450bece977
Remove CEF1 specific code since we only focus on CEF3. 2018-02-20 18:31:09 +01:00
Haojian Wu
02b72bee46
Integrate wxWebChromium to wxwidgets
Also add webview_chromium usage samples.
2018-02-20 18:31:03 +01:00