Merge branch 'macos_wkwebview' of https://github.com/TcT2k/wxWidgets

Use WKWebView for wxWebView Implementation under Apple systems.

See https://github.com/wxWidgets/wxWidgets/pull/2113
This commit is contained in:
Vadim Zeitlin
2021-01-16 16:20:58 +01:00
24 changed files with 394 additions and 2214 deletions

View File

@@ -1,152 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/html/webkit.h
// Purpose: wxWebKitCtrl - embeddable web kit control
// Author: Jethro Grassie / Kevin Ollivier
// Modified by:
// Created: 2004-4-16
// Copyright: (c) Jethro Grassie / Kevin Ollivier
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WEBKIT_H
#define _WX_WEBKIT_H
/**
@class wxWebKitCtrl
This control is a native wrapper around the Safari web browsing
engine. This wrapper differs from the one in wxWebView in that this
version supports functionality specific to WebKit, such as having
RunScript return a value, which is a very critical feature in many web
embedding scenarios.
This class is only available on macOS.
**/
class wxWebKitCtrl : public wxControl
{
public:
wxWebKitCtrl();
wxWebKitCtrl(wxWindow *parent,
wxWindowID winid,
const wxString& strURL,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxWebKitCtrlNameStr);
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& strURL,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxWebKitCtrlNameStr);
virtual ~wxWebKitCtrl();
void LoadURL(const wxString &url);
bool CanGoBack();
bool CanGoForward();
bool GoBack();
bool GoForward();
void Reload();
void Stop();
bool CanGetPageSource();
wxString GetPageSource();
void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
wxString GetPageURL();
void SetPageTitle(const wxString& title);
wxString GetPageTitle();
// since these worked in 2.6, add wrappers
void SetTitle(const wxString& title);
wxString GetTitle();
wxString GetSelection();
bool CanIncreaseTextSize();
void IncreaseTextSize();
bool CanDecreaseTextSize();
void DecreaseTextSize();
void Print(bool showPrompt = false);
void MakeEditable(bool enable = true);
bool IsEditable();
wxString RunScript(const wxString& javascript);
void SetScrollPos(int pos);
int GetScrollPos();
};
// ----------------------------------------------------------------------------
// Web Kit Events
// ----------------------------------------------------------------------------
enum {
wxWEBKIT_STATE_START = 1,
wxWEBKIT_STATE_NEGOTIATING = 2,
wxWEBKIT_STATE_REDIRECTING = 4,
wxWEBKIT_STATE_TRANSFERRING = 8,
wxWEBKIT_STATE_STOP = 16,
wxWEBKIT_STATE_FAILED = 32
};
enum {
wxWEBKIT_NAV_LINK_CLICKED = 1,
wxWEBKIT_NAV_BACK_NEXT = 2,
wxWEBKIT_NAV_FORM_SUBMITTED = 4,
wxWEBKIT_NAV_RELOAD = 8,
wxWEBKIT_NAV_FORM_RESUBMITTED = 16,
wxWEBKIT_NAV_OTHER = 32
};
class wxWebKitBeforeLoadEvent : public wxCommandEvent
{
public:
bool IsCancelled();
void Cancel(bool cancel = true);
wxString GetURL();
void SetURL(const wxString& url);
void SetNavigationType(int navType);
int GetNavigationType();
wxWebKitBeforeLoadEvent( wxWindow* win = 0 );
};
class wxWebKitStateChangedEvent : public wxCommandEvent
{
public:
int GetState();
void SetState(int state);
wxString GetURL();
void SetURL(const wxString& url);
wxWebKitStateChangedEvent( wxWindow* win = 0 );
};
class wxWebKitNewWindowEvent : public wxCommandEvent
{
public:
wxString GetURL() const;
void SetURL(const wxString& url);
wxString GetTargetName() const;
void SetTargetName(const wxString& name);
wxWebKitNewWindowEvent( wxWindow* win = 0 );
};
wxEventType wxEVT_WEBKIT_STATE_CHANGED;
wxEventType wxEVT_WEBKIT_BEFORE_LOAD;
wxEventType wxEVT_WEBKIT_NEW_WINDOW;
#endif
// _WX_WEBKIT_H_

View File

@@ -347,12 +347,13 @@ public:
and under Fedora it is webkitgtk4-devel. All wxWEBVIEW_WEBKIT features are
supported except for clearing and enabling / disabling the history.
@par wxWEBVIEW_WEBKIT (OSX)
@par wxWEBVIEW_WEBKIT (macOS)
The macOS WebKit backend uses Apple's
<a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/Reference/Reference.html#//apple_ref/doc/uid/20001903">WebView</a>
<a href="https://developer.apple.com/documentation/webkit/wkwebview">WKWebView</a>
class. This backend has full support for custom schemes and virtual file
systems.
systems on macOS 10.13+. In order to use handlers two-step creation has to be used
and RegisterHandler() has to be called before Create().
@section async Asynchronous Notifications
@@ -565,6 +566,9 @@ public:
/**
Registers a custom scheme handler.
@param handler A shared pointer to a wxWebHandler.
@note On macOS in order to use handlers two-step creation has to be
used and RegisterHandler() has to be called before Create().
With the other backends it has to be called after Create().
*/
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 0;
@@ -639,6 +643,8 @@ public:
Set the editable property of the web control. Enabling allows the user
to edit the page even if the @c contenteditable attribute is not set.
The exact capabilities vary with the backend being used.
@note This is not implemented on macOS.
*/
virtual void SetEditable(bool enable = true) = 0;
@@ -769,14 +775,14 @@ public:
/**
Clear the history, this will also remove the visible page.
@note This is not implemented on the WebKit2GTK+ backend.
@note This is not implemented on the WebKit2GTK+ backend and macOS.
*/
virtual void ClearHistory() = 0;
/**
Enable or disable the history. This will also clear the history.
@note This is not implemented on the WebKit2GTK+ backend.
@note This is not implemented on the WebKit2GTK+ backend and macOS.
*/
virtual void EnableHistory(bool enable = true) = 0;