remove dependency from former cocoa port
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76729 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,7 +23,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
|
#if defined( __WXCOCOA__ )
|
||||||
#include "wx/cocoa/string.h"
|
#include "wx/cocoa/string.h"
|
||||||
|
#endif
|
||||||
#include "wx/hashmap.h"
|
#include "wx/hashmap.h"
|
||||||
#include "wx/filesys.h"
|
#include "wx/filesys.h"
|
||||||
|
|
||||||
@@ -528,7 +530,7 @@ wxString wxWebViewWebKit::GetPageSource() const
|
|||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxStringWithNSString( source );
|
return wxCFStringRef::AsString( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
@@ -659,7 +661,7 @@ void wxWebViewWebKit::SetScrollPos(int pos)
|
|||||||
wxString javascript;
|
wxString javascript;
|
||||||
javascript.Printf(wxT("document.body.scrollTop = %d;"), pos);
|
javascript.Printf(wxT("document.body.scrollTop = %d;"), pos);
|
||||||
[[m_webView windowScriptObject] evaluateWebScript:
|
[[m_webView windowScriptObject] evaluateWebScript:
|
||||||
(NSString*)wxNSStringWithWxString( javascript )];
|
wxCFStringRef( javascript ).AsNSString()];
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxWebViewWebKit::GetSelectedText() const
|
wxString wxWebViewWebKit::GetSelectedText() const
|
||||||
@@ -668,7 +670,7 @@ wxString wxWebViewWebKit::GetSelectedText() const
|
|||||||
if ( !dr )
|
if ( !dr )
|
||||||
return wxString();
|
return wxString();
|
||||||
|
|
||||||
return wxStringWithNSString([dr toString]);
|
return wxCFStringRef::AsString([dr toString]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewWebKit::RunScript(const wxString& javascript)
|
void wxWebViewWebKit::RunScript(const wxString& javascript)
|
||||||
@@ -677,7 +679,7 @@ void wxWebViewWebKit::RunScript(const wxString& javascript)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
[[m_webView windowScriptObject] evaluateWebScript:
|
[[m_webView windowScriptObject] evaluateWebScript:
|
||||||
(NSString*)wxNSStringWithWxString( javascript )];
|
wxCFStringRef( javascript ).AsNSString()];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewWebKit::OnSize(wxSizeEvent &event)
|
void wxWebViewWebKit::OnSize(wxSizeEvent &event)
|
||||||
@@ -772,17 +774,17 @@ void wxWebViewWebKit::MacVisibilityChanged(){
|
|||||||
void wxWebViewWebKit::LoadURL(const wxString& url)
|
void wxWebViewWebKit::LoadURL(const wxString& url)
|
||||||
{
|
{
|
||||||
[[m_webView mainFrame] loadRequest:[NSURLRequest requestWithURL:
|
[[m_webView mainFrame] loadRequest:[NSURLRequest requestWithURL:
|
||||||
[NSURL URLWithString:wxNSStringWithWxString(url)]]];
|
[NSURL URLWithString:wxCFStringRef(url).AsNSString()]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxWebViewWebKit::GetCurrentURL() const
|
wxString wxWebViewWebKit::GetCurrentURL() const
|
||||||
{
|
{
|
||||||
return wxStringWithNSString([m_webView mainFrameURL]);
|
return wxCFStringRef::AsString([m_webView mainFrameURL]);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxWebViewWebKit::GetCurrentTitle() const
|
wxString wxWebViewWebKit::GetCurrentTitle() const
|
||||||
{
|
{
|
||||||
return wxStringWithNSString([m_webView mainFrameTitle]);
|
return wxCFStringRef::AsString([m_webView mainFrameTitle]);
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxWebViewWebKit::GetWebkitZoom() const
|
float wxWebViewWebKit::GetWebkitZoom() const
|
||||||
@@ -862,9 +864,9 @@ void wxWebViewWebKit::DoSetPage(const wxString& src, const wxString& baseUrl)
|
|||||||
if ( !m_webView )
|
if ( !m_webView )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[[m_webView mainFrame] loadHTMLString:(NSString*)wxNSStringWithWxString(src)
|
[[m_webView mainFrame] loadHTMLString:wxCFStringRef( src ).AsNSString()
|
||||||
baseURL:[NSURL URLWithString:
|
baseURL:[NSURL URLWithString:
|
||||||
wxNSStringWithWxString( baseUrl )]];
|
wxCFStringRef( baseUrl ).AsNSString()]];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewWebKit::Cut()
|
void wxWebViewWebKit::Cut()
|
||||||
@@ -929,14 +931,14 @@ wxString wxWebViewWebKit::GetSelectedSource() const
|
|||||||
if ( !dr )
|
if ( !dr )
|
||||||
return wxString();
|
return wxString();
|
||||||
|
|
||||||
return wxStringWithNSString([dr markupString]);
|
return wxCFStringRef::AsString([dr markupString]);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxWebViewWebKit::GetPageText() const
|
wxString wxWebViewWebKit::GetPageText() const
|
||||||
{
|
{
|
||||||
NSString *result = [m_webView stringByEvaluatingJavaScriptFromString:
|
NSString *result = [m_webView stringByEvaluatingJavaScriptFromString:
|
||||||
@"document.body.textContent"];
|
@"document.body.textContent"];
|
||||||
return wxStringWithNSString(result);
|
return wxCFStringRef::AsString(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewWebKit::EnableHistory(bool enable)
|
void wxWebViewWebKit::EnableHistory(bool enable)
|
||||||
@@ -961,8 +963,8 @@ wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory
|
|||||||
for(int i = -count; i < 0; i++)
|
for(int i = -count; i < 0; i++)
|
||||||
{
|
{
|
||||||
WebHistoryItem* item = [history itemAtIndex:i];
|
WebHistoryItem* item = [history itemAtIndex:i];
|
||||||
wxString url = wxStringWithNSString([item URLString]);
|
wxString url = wxCFStringRef::AsString([item URLString]);
|
||||||
wxString title = wxStringWithNSString([item title]);
|
wxString title = wxCFStringRef::AsString([item title]);
|
||||||
wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
|
wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
|
||||||
wxitem->m_histItem = item;
|
wxitem->m_histItem = item;
|
||||||
wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
|
wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
|
||||||
@@ -979,8 +981,8 @@ wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory(
|
|||||||
for(int i = 1; i <= count; i++)
|
for(int i = 1; i <= count; i++)
|
||||||
{
|
{
|
||||||
WebHistoryItem* item = [history itemAtIndex:i];
|
WebHistoryItem* item = [history itemAtIndex:i];
|
||||||
wxString url = wxStringWithNSString([item URLString]);
|
wxString url = wxCFStringRef::AsString([item URLString]);
|
||||||
wxString title = wxStringWithNSString([item title]);
|
wxString title = wxCFStringRef::AsString([item title]);
|
||||||
wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
|
wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
|
||||||
wxitem->m_histItem = item;
|
wxitem->m_histItem = item;
|
||||||
wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
|
wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
|
||||||
@@ -1052,10 +1054,10 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
|||||||
|
|
||||||
if (webKitWindow && frame == [sender mainFrame]){
|
if (webKitWindow && frame == [sender mainFrame]){
|
||||||
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
|
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
|
||||||
wxString target = wxStringWithNSString([frame name]);
|
wxString target = wxCFStringRef::AsString([frame name]);
|
||||||
wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATED,
|
wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATED,
|
||||||
webKitWindow->GetId(),
|
webKitWindow->GetId(),
|
||||||
wxStringWithNSString( url ),
|
wxCFStringRef::AsString( url ),
|
||||||
target);
|
target);
|
||||||
|
|
||||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||||
@@ -1070,10 +1072,10 @@ void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
|||||||
if (webKitWindow && frame == [sender mainFrame]){
|
if (webKitWindow && frame == [sender mainFrame]){
|
||||||
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
|
NSString *url = [[[[frame dataSource] request] URL] absoluteString];
|
||||||
|
|
||||||
wxString target = wxStringWithNSString([frame name]);
|
wxString target = wxCFStringRef::AsString([frame name]);
|
||||||
wxWebViewEvent event(wxEVT_WEBVIEW_LOADED,
|
wxWebViewEvent event(wxEVT_WEBVIEW_LOADED,
|
||||||
webKitWindow->GetId(),
|
webKitWindow->GetId(),
|
||||||
wxStringWithNSString( url ),
|
wxCFStringRef::AsString( url ),
|
||||||
target);
|
target);
|
||||||
|
|
||||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||||
@@ -1148,11 +1150,11 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString message = wxStringWithNSString([error localizedDescription]);
|
wxString message = wxCFStringRef::AsString([error localizedDescription]);
|
||||||
NSString* detail = [error localizedFailureReason];
|
NSString* detail = [error localizedFailureReason];
|
||||||
if (detail != NULL)
|
if (detail != NULL)
|
||||||
{
|
{
|
||||||
message = message + " (" + wxStringWithNSString(detail) + ")";
|
message = message + " (" + wxCFStringRef::AsString(detail) + ")";
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@@ -1169,7 +1171,7 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
wxString description = nsErrorToWxHtmlError(error, &type);
|
wxString description = nsErrorToWxHtmlError(error, &type);
|
||||||
wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
|
wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
|
||||||
webKitWindow->GetId(),
|
webKitWindow->GetId(),
|
||||||
wxStringWithNSString( url ),
|
wxCFStringRef::AsString( url ),
|
||||||
wxEmptyString);
|
wxEmptyString);
|
||||||
event.SetString(description);
|
event.SetString(description);
|
||||||
event.SetInt(type);
|
event.SetInt(type);
|
||||||
@@ -1195,7 +1197,7 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
wxString description = nsErrorToWxHtmlError(error, &type);
|
wxString description = nsErrorToWxHtmlError(error, &type);
|
||||||
wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
|
wxWebViewEvent event(wxEVT_WEBVIEW_ERROR,
|
||||||
webKitWindow->GetId(),
|
webKitWindow->GetId(),
|
||||||
wxStringWithNSString( url ),
|
wxCFStringRef::AsString( url ),
|
||||||
wxEmptyString);
|
wxEmptyString);
|
||||||
event.SetString(description);
|
event.SetString(description);
|
||||||
event.SetInt(type);
|
event.SetInt(type);
|
||||||
@@ -1208,13 +1210,13 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title
|
- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title
|
||||||
forFrame:(WebFrame *)frame
|
forFrame:(WebFrame *)frame
|
||||||
{
|
{
|
||||||
wxString target = wxStringWithNSString([frame name]);
|
wxString target = wxCFStringRef::AsString([frame name]);
|
||||||
wxWebViewEvent event(wxEVT_WEBVIEW_TITLE_CHANGED,
|
wxWebViewEvent event(wxEVT_WEBVIEW_TITLE_CHANGED,
|
||||||
webKitWindow->GetId(),
|
webKitWindow->GetId(),
|
||||||
webKitWindow->GetCurrentURL(),
|
webKitWindow->GetCurrentURL(),
|
||||||
target);
|
target);
|
||||||
|
|
||||||
event.SetString(wxStringWithNSString(title));
|
event.SetString(wxCFStringRef::AsString(title));
|
||||||
|
|
||||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||||
@@ -1240,10 +1242,10 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
|
|
||||||
webKitWindow->m_busy = true;
|
webKitWindow->m_busy = true;
|
||||||
NSString *url = [[request URL] absoluteString];
|
NSString *url = [[request URL] absoluteString];
|
||||||
wxString target = wxStringWithNSString([frame name]);
|
wxString target = wxCFStringRef::AsString([frame name]);
|
||||||
wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING,
|
wxWebViewEvent event(wxEVT_WEBVIEW_NAVIGATING,
|
||||||
webKitWindow->GetId(),
|
webKitWindow->GetId(),
|
||||||
wxStringWithNSString( url ), target);
|
wxCFStringRef::AsString( url ), target);
|
||||||
|
|
||||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||||
@@ -1270,7 +1272,7 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
NSString *url = [[request URL] absoluteString];
|
NSString *url = [[request URL] absoluteString];
|
||||||
wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
|
wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
|
||||||
webKitWindow->GetId(),
|
webKitWindow->GetId(),
|
||||||
wxStringWithNSString( url ), "");
|
wxCFStringRef::AsString( url ), "");
|
||||||
|
|
||||||
if (webKitWindow && webKitWindow->GetEventHandler())
|
if (webKitWindow && webKitWindow->GetEventHandler())
|
||||||
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
webKitWindow->GetEventHandler()->ProcessEvent(event);
|
||||||
@@ -1290,7 +1292,7 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
wxStringToWebHandlerMap::const_iterator it;
|
wxStringToWebHandlerMap::const_iterator it;
|
||||||
for( it = g_stringHandlerMap.begin(); it != g_stringHandlerMap.end(); ++it )
|
for( it = g_stringHandlerMap.begin(); it != g_stringHandlerMap.end(); ++it )
|
||||||
{
|
{
|
||||||
if(it->first.IsSameAs(wxStringWithNSString(scheme)))
|
if(it->first.IsSameAs(wxCFStringRef::AsString(scheme)))
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -1312,8 +1314,8 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
|
|
||||||
id<NSURLProtocolClient> client = [self client];
|
id<NSURLProtocolClient> client = [self client];
|
||||||
|
|
||||||
wxString wxpath = wxStringWithNSString(path);
|
wxString wxpath = wxCFStringRef::AsString(path);
|
||||||
wxString scheme = wxStringWithNSString([[request URL] scheme]);
|
wxString scheme = wxCFStringRef::AsString([[request URL] scheme]);
|
||||||
wxFSFile* file = g_stringHandlerMap[scheme]->GetFile(wxpath);
|
wxFSFile* file = g_stringHandlerMap[scheme]->GetFile(wxpath);
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
@@ -1331,7 +1333,7 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebViewNavigationError* out)
|
|||||||
|
|
||||||
|
|
||||||
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[request URL]
|
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[request URL]
|
||||||
MIMEType:wxNSStringWithWxString(file->GetMimeType())
|
MIMEType:wxCFStringRef(file->GetMimeType()).AsNSString()
|
||||||
expectedContentLength:length
|
expectedContentLength:length
|
||||||
textEncodingName:nil];
|
textEncodingName:nil];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user