macOS/iOS: Use WKWebView for wxWebView Implementation
WKWebView replaces WebView on macOS (available since 10.10, deprecated since 10.14) and UIWebView on iOS (available since 8.0 deprecated since 10.0). Using WKWebView ensures future compatiblity and unifies the interface used for iOS and macOS.
This commit is contained in:
@@ -2789,6 +2789,7 @@ DECLARE_WXCOCOA_OBJC_CLASS(NSRotationGestureRecognizer);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSPressGestureRecognizer);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSTouch);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSPasteboard);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(WKWebView);
|
||||
|
||||
typedef WX_NSWindow WXWindow;
|
||||
typedef WX_NSView WXWidget;
|
||||
@@ -2797,6 +2798,7 @@ typedef WX_NSMenu WXHMENU;
|
||||
typedef WX_NSOpenGLPixelFormat WXGLPixelFormat;
|
||||
typedef WX_NSOpenGLContext WXGLContext;
|
||||
typedef WX_NSPasteboard OSXPasteboard;
|
||||
typedef WX_WKWebView OSXWebViewPtr;
|
||||
|
||||
#elif wxOSX_USE_IPHONE
|
||||
|
||||
@@ -2810,7 +2812,6 @@ DECLARE_WXCOCOA_OBJC_CLASS(UIImage);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(UIEvent);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(NSSet);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(EAGLContext);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(UIWebView);
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(UIPasteboard);
|
||||
|
||||
typedef WX_UIWindow WXWindow;
|
||||
@@ -2819,15 +2820,10 @@ typedef WX_UIImage WXImage;
|
||||
typedef WX_UIMenu WXHMENU;
|
||||
typedef WX_EAGLContext WXGLContext;
|
||||
typedef WX_NSString WXGLPixelFormat;
|
||||
typedef WX_UIWebView OSXWebViewPtr;
|
||||
typedef WX_UIPasteboard WXOSXPasteboard;
|
||||
|
||||
#endif
|
||||
|
||||
#if wxOSX_USE_COCOA_OR_CARBON
|
||||
DECLARE_WXCOCOA_OBJC_CLASS(WebView);
|
||||
typedef WX_WebView OSXWebViewPtr;
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __WXMAC__ */
|
||||
|
@@ -25,6 +25,8 @@
|
||||
// Web Kit Control
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebViewHandler>, wxStringToWebHandlerMap);
|
||||
|
||||
class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
|
||||
{
|
||||
public:
|
||||
@@ -71,7 +73,7 @@ public:
|
||||
virtual wxWebViewZoomType GetZoomType() const wxOVERRIDE;
|
||||
virtual bool CanSetZoomType(wxWebViewZoomType type) const wxOVERRIDE;
|
||||
|
||||
virtual bool IsBusy() const wxOVERRIDE { return m_busy; }
|
||||
virtual bool IsBusy() const wxOVERRIDE;
|
||||
|
||||
//History functions
|
||||
virtual void ClearHistory() wxOVERRIDE;
|
||||
@@ -121,54 +123,21 @@ public:
|
||||
|
||||
virtual void* GetNativeBackend() const wxOVERRIDE { return m_webView; }
|
||||
|
||||
// ---- methods not from the parent (common) interface
|
||||
bool CanGetPageSource() const;
|
||||
|
||||
void SetScrollPos(int pos);
|
||||
int GetScrollPos();
|
||||
|
||||
bool CanIncreaseTextSize() const;
|
||||
void IncreaseTextSize();
|
||||
bool CanDecreaseTextSize() const;
|
||||
void DecreaseTextSize();
|
||||
|
||||
float GetWebkitZoom() const;
|
||||
void SetWebkitZoom(float zoom);
|
||||
|
||||
// don't hide base class virtuals
|
||||
virtual void SetScrollPos( int orient, int pos, bool refresh = true ) wxOVERRIDE
|
||||
{ return wxControl::SetScrollPos(orient, pos, refresh); }
|
||||
virtual int GetScrollPos( int orient ) const wxOVERRIDE
|
||||
{ return wxControl::GetScrollPos(orient); }
|
||||
|
||||
//we need to resize the webview when the control size changes
|
||||
void OnSize(wxSizeEvent &event);
|
||||
void OnMove(wxMoveEvent &event);
|
||||
void OnMouseEvents(wxMouseEvent &event);
|
||||
|
||||
bool m_busy;
|
||||
bool m_nextNavigationIsNewWindow;
|
||||
|
||||
protected:
|
||||
virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE;
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
void MacVisibilityChanged() wxOVERRIDE;
|
||||
|
||||
private:
|
||||
wxWindow *m_parent;
|
||||
wxWindowID m_windowID;
|
||||
wxString m_pageTitle;
|
||||
|
||||
OSXWebViewPtr m_webView;
|
||||
wxStringToWebHandlerMap m_handlers;
|
||||
|
||||
WX_NSObject m_loadDelegate;
|
||||
WX_NSObject m_policyDelegate;
|
||||
WX_NSObject m_navigationDelegate;
|
||||
WX_NSObject m_UIDelegate;
|
||||
|
||||
// we may use this later to setup our own mouse events,
|
||||
// so leave it in for now.
|
||||
void* m_webKitCtrlEventHandler;
|
||||
bool RunScriptSync(const wxString& javascript, wxString* output = NULL);
|
||||
bool QueryCommandEnabled(const wxString& command) const;
|
||||
void ExecCommand(const wxString& command);
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_WEBVIEW wxWebViewFactoryWebKit : public wxWebViewFactory
|
||||
|
@@ -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;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user