adding minimal ios support for webview

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2014-03-31 07:55:36 +00:00
parent b7b24349e1
commit 1b32b97966
4 changed files with 42 additions and 16 deletions

View File

@@ -14,8 +14,7 @@
#include "wx/setup.h"
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && (defined(__WXOSX_COCOA__) \
|| defined(__WXOSX_CARBON__))
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX__)
#include "wx/control.h"
#include "wx/webview.h"

View File

@@ -11,8 +11,7 @@
#include "wx/setup.h"
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && (defined(__WXOSX_COCOA__) \
|| defined(__WXOSX_CARBON__))
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX__)
#include "wx/osx/core/objcid.h"

View File

@@ -17,7 +17,7 @@
#include "wx/webview.h"
#if defined(__WXOSX_COCOA__) || defined(__WXOSX_CARBON__)
#if defined(__WXOSX__)
#include "wx/osx/webview_webkit.h"
#elif defined(__WXGTK__)
#include "wx/gtk/webview_webkit.h"

View File

@@ -13,8 +13,7 @@
#include "wx/osx/webview_webkit.h"
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && (defined(__WXOSX_COCOA__) \
|| defined(__WXOSX_CARBON__))
#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX__)
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
@@ -28,12 +27,26 @@
#include "wx/hashmap.h"
#include "wx/filesys.h"
#if wxOSX_USE_IPHONE
#include <UIKit/UIWebView.h>
#else
#include <WebKit/WebKit.h>
#include <WebKit/HIWebView.h>
#include <WebKit/CarbonUtils.h>
#endif
#include <Foundation/NSURLError.h>
// using native types to get compile errors and warnings
#if wxOSX_USE_COCOA_OR_CARBON
typedef WebView OSXWebView;
#elif wxOSX_USE_IPHONE
typedef UIWebView OSXWebView;
#else
#error "unsupport OSX variant"
#endif
#define DEBUG_WEBKIT_SIZING 0
// ----------------------------------------------------------------------------
@@ -357,6 +370,12 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
GetEventTypeCount(eventList), eventList, this,
(EventHandlerRef *)&m_webKitCtrlEventHandler);
SetPeer(peer);
#elif wxOSX_USE_IPHONE
CGRect r = wxOSXGetFrameForControl( this, pos , size ) ;
m_webView = [[UIWebView alloc] initWithFrame:r];
SetPeer( new wxWidgetIPhoneImpl( this, m_webView ) );
#else
NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
m_webView = [[WebView alloc] initWithFrame:r
@@ -373,8 +392,9 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
[m_webView setHidden:false];
// Register event listener interfaces
#if wxOSX_USE_IPHONE
#else
WebViewLoadDelegate* loadDelegate =
[[WebViewLoadDelegate alloc] initWithWxWindow: this];
@@ -390,7 +410,7 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
[[WebViewUIDelegate alloc] initWithWxWindow: this];
[m_webView setUIDelegate:uiDelegate];
#endif
//Register our own class for custom scheme handling
[NSURLProtocol registerClass:[WebViewCustomProtocol class]];
@@ -400,6 +420,8 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
wxWebViewWebKit::~wxWebViewWebKit()
{
#if wxOSX_USE_IPHONE
#else
WebViewLoadDelegate* loadDelegate = [m_webView frameLoadDelegate];
WebViewPolicyDelegate* policyDelegate = [m_webView policyDelegate];
WebViewUIDelegate* uiDelegate = [m_webView UIDelegate];
@@ -415,6 +437,7 @@ wxWebViewWebKit::~wxWebViewWebKit()
if (uiDelegate)
[uiDelegate release];
#endif
}
// ----------------------------------------------------------------------------
@@ -442,7 +465,7 @@ void wxWebViewWebKit::GoBack()
if ( !m_webView )
return;
[(WebView*)m_webView goBack];
[(OSXWebView*)m_webView goBack];
}
void wxWebViewWebKit::GoForward()
@@ -450,7 +473,7 @@ void wxWebViewWebKit::GoForward()
if ( !m_webView )
return;
[(WebView*)m_webView goForward];
[(OSXWebView*)m_webView goForward];
}
void wxWebViewWebKit::Reload(wxWebViewReloadFlags flags)
@@ -849,7 +872,7 @@ void wxWebViewWebKit::Cut()
if ( !m_webView )
return;
[(WebView*)m_webView cut:m_webView];
[(OSXWebView*)m_webView cut:m_webView];
}
void wxWebViewWebKit::Copy()
@@ -857,7 +880,7 @@ void wxWebViewWebKit::Copy()
if ( !m_webView )
return;
[(WebView*)m_webView copy:m_webView];
[(OSXWebView*)m_webView copy:m_webView];
}
void wxWebViewWebKit::Paste()
@@ -865,7 +888,7 @@ void wxWebViewWebKit::Paste()
if ( !m_webView )
return;
[(WebView*)m_webView paste:m_webView];
[(OSXWebView*)m_webView paste:m_webView];
}
void wxWebViewWebKit::DeleteSelection()
@@ -873,7 +896,7 @@ void wxWebViewWebKit::DeleteSelection()
if ( !m_webView )
return;
[(WebView*)m_webView deleteSelection];
[(OSXWebView*)m_webView deleteSelection];
}
bool wxWebViewWebKit::HasSelection() const
@@ -1000,6 +1023,9 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
// Listener interfaces
//------------------------------------------------------------
#if wxOSX_USE_IPHONE
#else
// NB: I'm still tracking this down, but it appears the Cocoa window
// still has these events fired on it while the Carbon control is being
// destroyed. Therefore, we must be careful to check both the existence
@@ -1253,6 +1279,8 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
}
@end
#endif
@implementation WebViewCustomProtocol
+ (BOOL)canInitWithRequest:(NSURLRequest *)request